The process cannot access the file

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

Guest

I use the following code to create a new FileStream

Dim fs As New FileStream(txtSourceFile.Text, FileMode.Open, FileAccess.Read, FileShare.None

where txtSourceFile is a text box which contains the path to the specified file

The problem is that whenever I try to open a file with the extension ".doc"
I get the following exception thrown at my face

An unhandled exception of type 'System.IO.IOException' occurred in mscorlib.dl
Additional information: The process cannot access the file "C:\Documents and Settings\My Documents\myFile.doc" because it is being used by another process

with other file formats (gif,jpg,pdf,etc.) the program works fine

How can I solve the problem

Thanks in advance
ALO
 
Three more important clarifications
1. This is a window application (not web
2. I am using VS.NET 200
3. I am using Windows XP pr
 
Someone else (or your own program) has opened the file already.

Willy.
 
Back
Top