File IO Error!!!

V

Vai2000

Hi All, I am using File.Copy operation inside my program. I am running into
this error, any clues how to fix this?
I am using this syntax for reading the file
freader = new FileStream(this.fileName, FileMode.Open, FileAccess.Read,
FileShare.ReadWrite);The process cannot access the file "c:\temp\foo.txt" because it is being
used by another process.
Stack Trace:
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath,
Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share)
TIA
 
J

Jared Parsons [MSFT]

This means that some process has this file opened already. Do you use this
file anywhere else in your process? If so, make sure that you close this
file when you are done with it.

Otherwise, go to www.sysinternals.com and download handle.exe. This will
allow you to see which process has that file open.

--
Jared Parson [MSFT]
(e-mail address removed)

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
 

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