티스토리 뷰
반응형
[unity/c#/wpf] 파일로 텍스트/로그 쓰기
#사용
void Update()
{
if(Input.GetKeyUp("a")){
WriteTxt(@"c:\donwload\a.text", "hello");
}
}
#구현
void WriteTxt(string filePath, string message)
{
DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(filePath));
if (!directoryInfo.Exists)
{
directoryInfo.Create();
}
FileStream fileStream
= new FileStream(filePath, FileMode.Append, FileAccess.Write);
StreamWriter writer = new StreamWriter(fileStream, System.Text.Encoding.Unicode);
writer.WriteLine(message);
writer.Close();
}
#로그 #텍스트 #파일쓰기
반응형
'c#' 카테고리의 다른 글
[wpf/c#] 페이드 인 아웃 이펙트 구현 (0) | 2022.10.27 |
---|---|
[wpf/c#] vlc player 개발 및 라이브러리 사용법 (0) | 2022.10.27 |
[c#/unity] 시스템 볼륨(system volumn) 제어하기 ( CoreAudio 사용) (0) | 2022.03.23 |
[unity/ wpf/c#] newton json Serialize/deSerialize(ToJson/ToObject) 엄청 쉽게 하는법 (0) | 2022.03.16 |
[c#/wpf/mvvm] [wpf/c#] mvvm 을 활용한 런처(전원 관리 및 파일 관리) 만들기(3/3) FTP 파일 다운로드 / 앱 자동 실행 / Config파일 (0) | 2022.03.02 |
댓글
반응형