System.IO.File.Create("文件路徑")
前提確保有此路徑, 否則會報錯
本以為創建文件是會自動釋放的, 結果沒有自動釋放 ,
fs.Write(responseBytes, 0, responseBytes.Length); fs.Close(); UTF8Encoding utf8 = new UTF8Encoding(false); String spath = RcvPath + "/xml/sdata.json"; if (!File.Exists(spath)) { String sFloderpath = RcvPath + "/xml"; if (!Directory.Exists(sFloderpath)) { Directory.CreateDirectory(sFloderpath); } System.IO.File.Create(spath).Dispose(); } StreamWriter strMyCreate = new StreamWriter(spath, false, utf8); String lastupdatetime = downloadWebClient.ResponseHeaders.GetValues("lastupdatetime")[0].ToString(); strMyCreate.WriteLine("{\"lastUpdateTime\":\"" + lastupdatetime + "\"}"); strMyCreate.Close();
結果造就了第一次只創建文件 , 並不寫入 , 執行第二次的時候才會寫入
Dispose是創建文件后釋放 , 好像是W3P什么來着