FileMode.Create is what I use, does what you ask.
Create Specifies that the operating system should create a new file. If the file already exists, it will be overwritten. This requires FileIOPermissionAccess.Write permission. FileMode.Create is equivalent to requesting that if the file does not exist, use CreateNew; otherwise, use Truncate. If the file already exists but is a hidden file, an UnauthorizedAccessException exception is thrown.
[link text][1]
[1]: https://msdn.microsoft.com/en-us/library/system.io.filemode(v=vs.110).aspx
↧