What's the difference, if any?
None.
File.Open is, internally, nothing more than:
public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share)
{
return new FileStream(path, mode, access, share);
}
If you don't use the overload which specifies a FileAccess and FileShare, it specifies this for you (using FileShare.None, and FileAccess.Write on append or ReadWrite otherwise).
That being said, this is an implementation detail, not part of the documentation. Technically, a future .NET Framework release could use a different implementation, although I find that unlikely.
File.Open()
is a convenience method. Internally it is implemented as:
public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share)
{
return new FileStream(path, mode, access, share);
}
This kind of duplication is very rare in the .NET framework. But there's a story about this one, told by Krzysztof Cwalina in this lecture. They did a usability study on an early version of the framework, asking a bunch of experienced (but otherwise .NET agnostic) programmers to write some code using the FileStream and StreadReader/Writer classes.
It didn't go well, they got a 100% fail rate. They responded by adding methods to the System.IO.File class, using the "most likely to fall into the pit of success" approach.
Cool video btw, if you're at all into the reasons the framework looks the way it looks.
Better post a real answer: the File.Open() method calls the FileStream constructor, passing values for FileAccess and FileShare (if you don't specify them) that are most likely to do the Right Thing. Which is FileAccess.ReadWrite and FileShare.None.