//建立临时文件 string tempFile = Path.GetTempFileName(); string ls_fileNeme = System.IO.Path.ChangeExtension(ls_file, ".rep"); File.Move(ls_file, ls_fileNeme);//修改文件扩展名 using (FileStream fs = new FileStream(ls_fileNeme, FileMode.Open)) { StreamWriter sw = new StreamWriter(fs, Encoding.Unicode); sw.WriteLine("what are you doing"); sw.Flush(); sw.Close(); }