SMALL
리스트 저장버튼 만든후
함수생성
private void buttonTopicSave_Click(object sender, EventArgs e)
{
StreamWriter sw;
sw = new StreamWriter("Sub.txt");
int nCount = listBoxSub.Items.Count;
for (int i = 0; i < nCount; i++)
{
listBoxSub.Items[i] += "\r\n";
sw.Write(listBoxSub.Items[i]);
}
sw.Close();
}
생성된 패스값 불러와서 리스트박스로 가져오기
private void buttonTopicOpen_Click(object sender, EventArgs e)
{
string currentPath = System.IO.Directory.GetCurrentDirectory();
StreamReader file = new StreamReader(currentPath + "\\Sub.txt", Encoding.Default);
string s = "";
while (s != null)
{
s = file.ReadLine();
if (!string.IsNullOrEmpty(s)) listBoxSub.Items.Add(s);
}
file.Close();
}
LIST
'일반' 카테고리의 다른 글
System.IO 파일입출력 텍스트모드 바이너리모드 (0) | 2022.03.10 |
---|---|
로그파일저장 (0) | 2022.03.10 |
C# 현재경로로 파일 저장하기 (0) | 2022.03.07 |
C# ini 저장해서 재실행시 불러오기 (0) | 2022.03.07 |
mosquitto conf (0) | 2022.03.07 |