为了安全 我把文件的头改了,所以每次要用这个文件的时候在改回来,不用的的时候在改掉
byte[] buff1 = new byte[] { 0, 1, 0, 0, 83, 116, 97, 110, 100, 97, 114, 100, 32, 74, 101 };
FileStream fs = new FileStream(Common.Share.ClientDb, FileMode.Open);
fs.Seek(0, SeekOrigin.Begin);
fs.Write(buff1, 0, 15);
fs.Flush();
fs.Close(); 但是文件使用的比较频繁,会出现被另一线程所占用的异常
所以我想能不能每次的要用文件的时候 不用改回去 请高手指点指点!
byte[] buff1 = new byte[] { 0, 1, 0, 0, 83, 116, 97, 110, 100, 97, 114, 100, 32, 74, 101 };
FileStream fs = new FileStream(Common.Share.ClientDb, FileMode.Open);
fs.Seek(0, SeekOrigin.Begin);
fs.Write(buff1, 0, 15);
fs.Flush();
fs.Close(); 但是文件使用的比较频繁,会出现被另一线程所占用的异常
所以我想能不能每次的要用文件的时候 不用改回去 请高手指点指点!
你把两个byte[]合到一起写啊
{ fs.Write(buff1, 0, 15); }
sw.WriteLine("Time:" );
sw.WriteLine("--------------------------------");
sw.Flush();
sw.Close();这种方式可以追加数据