System.IO.File.Create("文件路径")json
前提确保有此路径, 不然会报错spa
本觉得建立文件是会自动释放的, 结果没有自动释放 , xml
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();
结果造就了第一次只建立文件 , 并不写入 , 执行第二次的时候才会写入blog
Dispose是建立文件后释放 , 好像是W3P什么来着 it