首页 > 代码库 > winform 写入txt

winform 写入txt

StreamWriter sw;

FileStream fs = new FileStream(@"D:\" + txtStringfield03.Text + ".txt", FileMode.OpenOrCreate, FileAccess.Write);
                            sw = new StreamWriter(fs, System.Text.Encoding.GetEncoding("GB2312"));
                            sw.Flush();
                            sw.BaseStream.Seek(0, SeekOrigin.Begin);
                            ee.Opens(strFileDrls);

 

sw.WriteLine();
                    sw.WriteLine();
                    sw.WriteLine(p_DECD);
                    sw.WriteLine();
                    sw.WriteLine();

sw.Flush();
sw.Close();

但是在这个程序中加入txt文件的名称存在,将会自动重写您的这个文件

 

winform 写入txt