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

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.
 
M

Morten Wennevik

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top