写文件时的问题,请指教一下 呵呵
private void rfsStorageFiles(byte[] filesStream)
{
try
{
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
{
StreamWriter writer = new StreamWriter(new IsolatedStorageFileStream("myFile222.db", FileMode.Append, store));
writer.Write(filesStream);
writer.Close();
}
}
catch (Exception err)
{
MessageBox.Show(err.Message.ToString());
}
}
本意是, 将一个字节数组内容,写入一个文件里,但是现在,发现没有写进去呀
怎么才能写进去呢?
自己数组内容是 16进制的, 如 0x53,0x51....
------解决方案--------------------writer.Commit();
------解决方案--------------------汗,丢人了。是
C# code
writer.Flush();
------解决方案--------------------
C# code
//写信息
public static void writewatchGoods(string SqlMessage, string fileName)
{
//fileName = "GoodsInfo.txt";
if (!File.Exists(fileName))
{
StreamWriter w = File.AppendText(fileName);
w.WriteLine(SqlMessage);
w.Flush();
w.Close();
}
else
{
StreamWriter w1 = File.AppendText(fileName);
w1.WriteLine("\r\n" + SqlMessage);
w1.Flush();
w1.Close();
}
}
------解决方案--------------------
C# code
writer.Write(filesStream);
------解决方案--------------------