473,322 Members | 1,911 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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

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
4 2035
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: RSB | last post by:
Hi Every one, I am currently using Visual Studio .Net and trying to open a project from SourceSafe and once i open the project for the first time i get the following error/warning... "The...
0
by: sam | last post by:
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...
1
by: Peter Schmitz | last post by:
Hi, I'm just trying to play a *.wav file, making use of the unmanaged function "sndPlaySoundA" in winmm.dll, but I still got one question: How can I avoid, that the sound file itself has to be...
3
by: Daniel | last post by:
if System.IO.StreamWriter write throws an exception, is there anyway to close the System.IO.StreamWriter object? it seems to stay open when this happens then future attempts to write to that same...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
2
by: kk.simhadri | last post by:
Hi everybody, I want to run a bat file which is on different PC in the same network. I am able to run a batch file in my PC through the following code <% set wshell =...
2
by: thirunavukarasukm | last post by:
Hai.... "i want used confirm in javascript in code behind" i am used confirm button ,,,in code behind. if the confirm button worked the function is return the true...
2
by: aaron.watters | last post by:
Hi. I'm writing an archival system which I'd like to be portable to Windows. The system relies on the property of Unix which allows a process to keep a file open even if another process renames...
4
by: JaxDawg | last post by:
I have a spreadsheet saved as an XML spreadsheet so I can manipulate it easier (and don't need COM). When I'm done, I want to display to the user. Currently, I'm using simple JavaScript in my PHP...
0
by: trixxnixon | last post by:
i have a form that is being designed to pend requests in a requests database. the pend form is opened from an update form used by an employee to enter updates. when the pend form is updated, the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.