This is in relation to this other SO question which asks how to overwrite an existing file.
The top answer is this:
FileStream file = File.Open("text.txt", FileMode.Create);
My answer was this:
FileStream fs = System.IO.File.Create(fileName);
As of when I wrote this question, the tally was 14-0 in favor of Open
.
If votes are an indication of good versus bad solutions, this makes me wonder a bit:
Is there something I'm missing in
these methods that would make it
clearly that much better to choose
Open
overCreate
?
Best Solution
To me, I know exactly what
File.Open("...", FileMode.Create)
does because I can hover overFileMode.Create
and it tells me that is will create a new file each time.File.Create("...")
has no such tool tip that indicates that it will do this.