By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,197 Members | 1,670 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,197 IT Pros & Developers. It's quick & easy.

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

P: n/a
sam
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.
Jul 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Try to open the file in read-only mode it should work. Even in notepad
if you try to save the opened document it won't let you.

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

sam wrote:
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.

Jul 21 '05 #2

P: n/a
Try to open the file in read-only mode it should work. Even in notepad
if you try to save the opened document it won't let you.

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

sam wrote:
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.

Jul 21 '05 #3

P: n/a
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).

--
Happy Coding!
Morten Wennevik [C# MVP]
Jul 21 '05 #4

P: n/a
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).

--
Happy Coding!
Morten Wennevik [C# MVP]
Jul 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.