The .Net library has the method System.IO.File.Create(), which is like File.OpenWrite() (and hence ZlpFileInfo.OpenWrite()) except that if the file already exists, it is truncated to zero bytes. If you do something like this:
using (FileStream fs = new ZlpFileInfo("Lalala.txt").OpenWrite())
using (StreamWriter sw = new StreamWriter(fs))
{
sw.WriteLine("AAAAAAAAAAAAAAAAAAAA");
}
using (FileStream fs = new ZlpFileInfo("Lalala.txt").OpenWrite())
using (StreamWriter sw = new StreamWriter(fs))
{
sw.WriteLine("BBBBB");
}
... Lalala.txt has the following contents:
BBBBB
AAAAAAAAAAAAA
Whereas with my addition, if you replace OpenWrite() with OpenCreate(), Lalala.txt contains only BBBBB.
The .Net library has the method
System.IO.File.Create()
, which is likeFile.OpenWrite()
(and henceZlpFileInfo.OpenWrite()
) except that if the file already exists, it is truncated to zero bytes. If you do something like this:... Lalala.txt has the following contents:
Whereas with my addition, if you replace OpenWrite() with OpenCreate(), Lalala.txt contains only
BBBBB
.