How to open a file which is currently being used by another proces

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have to open a files for reading, which is currently being used by another
process(say file X). I could open file X in notepad, without any issues. How
can I open it in vb.net? I always get an error saying that file is being used
by another process. Any help please.
 
Hi Sam,

If the file can be opened by Notepad then you should be able to open it in
your program too. Specify that you only need to Read the file and Share
it.
Simply using File.OpenRead() might work, or you can do a more complex
File.Open Method (filename, FileMode.Open, FileAccess.Read,
FileShare.ReadWrite)
(Not entirely sure what would be the best FileShare selection, you might
want to try the various options).
 
Back
Top