SMALL
MQTT 로그에서 TOPIC과 PAYLOAD를 저장
함수로 TOPIC인자와 PAYLOAD인자받기
private void logSave2(string topic, string payload)
{
string currentPath = System.IO.Directory.GetCurrentDirectory();
string[] lines = {DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff - ") + topic + " - " + payload};
using (StreamWriter Write = new StreamWriter(@"" + currentPath + "\\Log\\" + "log-MQTT-" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt",true))
{
foreach (string line in lines)
{
Write.WriteLine(line);
}
}
using System.IO;
string Path = @"경로\Write.txt";
string[] lines = {"첫번째 줄", "두번째 줄", "세번째줄"};
using (StreamWriter Write = new StreamWriter(path))
{
foreach (string line in lines)
{
Write.WriteLine(line);
}
}
using (StreamWriter Write = new StreamWriter(path, true))
{
foreach (string line in lines)
{
Write.WriteLine(line);
}
}
LIST
'일반' 카테고리의 다른 글
SERIALIZE DESERIALIZE (0) | 2022.03.14 |
---|---|
System.IO 파일입출력 텍스트모드 바이너리모드 (0) | 2022.03.10 |
C# listbox 텍스트파일 저장후 불러오기 (0) | 2022.03.07 |
C# 현재경로로 파일 저장하기 (0) | 2022.03.07 |
C# ini 저장해서 재실행시 불러오기 (0) | 2022.03.07 |