P
PJ
Hi all,
I have two option to open a file stream
1. Dim mStream As Stream = New FileStream(localFile, FileMode.Open,
FileAccess.Read)
This works fine as long as the file is closed. If a file is being opened by
another process (even a .log or .txt file), it fails.
2. Dim mStream As Stream = File.Open(localFile, FileMode.Open,
FileAccess.Read, FileShare.ReadWrite)
This works fine as long as the file is closed. However, if the file is .txt
or .log, it works fine EVEN IF the file is open (Failed when I used option
1)
My question is, can I use option 2 or I have to use option 1 for this? What
are the differences? Thanks. I use in my FTP class.
I have two option to open a file stream
1. Dim mStream As Stream = New FileStream(localFile, FileMode.Open,
FileAccess.Read)
This works fine as long as the file is closed. If a file is being opened by
another process (even a .log or .txt file), it fails.
2. Dim mStream As Stream = File.Open(localFile, FileMode.Open,
FileAccess.Read, FileShare.ReadWrite)
This works fine as long as the file is closed. However, if the file is .txt
or .log, it works fine EVEN IF the file is open (Failed when I used option
1)
My question is, can I use option 2 or I have to use option 1 for this? What
are the differences? Thanks. I use in my FTP class.