Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between 'File.Open()' and 'new FileStream()'

Tags:

What's the difference, if any?

like image 611
anthony Avatar asked Mar 03 '10 22:03

anthony


1 Answers

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.

like image 135
Reed Copsey Avatar answered Sep 23 '22 20:09

Reed Copsey