According to documentation, “it is opened sharing Read access (that is, requests to open the file for writing by this or another process will fail until the FileStream
object has been closed, but read attempts will succeed)” [https://learn.microsoft.com/en-us/dotnet/api/system.io.filestream.-ctor?view=netframework-4.0#system-io-filestream-ctor(system-string-system-io-filemode-system-io-fileaccess)].
FileShare Enum
Hello,
My case is vb.net:
Using imp As New FileStream(LoadTextBox.Text, FileMode.Open, FileAccess.Read)
Using exp As New FileStream(SaveTextBox.Text, FileMode.Create, FileAccess.Write)
...
End Using
only above 2 constructures, anyhow, since I don't specify the FileShare Enum, what's the default behavior for each one? (.netfw 4.0)
-
Viorel 118K Reputation points
2023-04-02T15:50:52.85+00:00
1 additional answer
Sort by: Most helpful
-
Dewayne Basnett 1,366 Reputation points
2023-04-03T17:44:28.1333333+00:00 From the Remarks here, https://learn.microsoft.com/en-us/dotnet/api/system.io.filestream.-ctor?view=netframework-4.8.1#system-io-filestream-ctor(microsoft-win32-safehandles-safefilehandle-system-io-fileaccess) It says "FileShare.Read is the default for those FileStream constructors without a FileShare parameter."