public void WriteFile( string filepath, List< string > list) { int index = 0; System.IO.FileStream fileStream = new System.IO.FileStream(filepath,System.IO.FileMode.Create); System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(fileStream); //streamWriter.Write(content); streamWriter.Flush(); streamWriter.BaseStream.Seek(0,System.IO.SeekOrigin.Begin); list.ForEach(item => { streamWriter.WriteLine( "第" +(index++)+ "条记录->" +item); }); streamWriter.Flush(); streamWriter.Close(); fileStream.Close(); } |