c# winform 把文件写入硬盘,创建文件并写入值,流控制文件

创建文件并写入值

FileStream fs1 = new FileStream(Application.StartupPath + "\\AlarmSet.txt", FileMode.Create, FileAccess.Write);//创建文件
StreamWriter sw = new StreamWriter(fs1);
sw.WriteLine("[runtype]");//写入值
sw.WriteLine("type=1");
sw.WriteLine("\r\n");
		
sw.WriteLine("--报警设置 PPWS 号牌匹配位数 PPWZ 匹配位置 0前匹配 1后匹配");
sw.WriteLine("[Alarm]");
sw.WriteLine("PPWZ=0");
sw.WriteLine("PPWS=8");
sw.WriteLine("\r\n");
sw.WriteLine("[Server]");
sw.WriteLine("ListenPort=2005");
sw.WriteLine("\r\n");
sw.WriteLine("[Form]");
sw.WriteLine("PPWZ=0");

sw.Close();
fs1.Close();


黑色头发:http://heisetoufa.iteye.com

你可能感兴趣的:(C++,c,C#,WinForm)