C#讀寫txt需要用到文件流,首先需要包含文件流的命名空間using System.IO,然後需要定義一個StreamWriter變量,設置文件的保存位置
//測試,C#寫txt
public StreamWriter testwrite = newStreamWriter(@"d:\\testwrite.txt",true);
然後通過下面語句進行寫入txt
testwrite.Write(Convert.ToString(RadarLongitude) );testwrite.Flush();
使用完成後,需要關閉這個流,也就是
testwrite.Close();