470,591 Members | 1,440 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,591 developers. It's quick & easy.

C# System.IO.File.Move () with "Access denied" error

To all,

I've tried to use System.IO.File.Move (srcFile, desFile);
but there is an exception similar to this :
The process can't access desFile because it's being used by another
process

I think that it's strange since I've already closed the FileStreams
associated to all available files already....

Any clues ??

From Jason (Kusanagihk)
Nov 16 '05 #1
4 14546
This is a standart situation, the error message gives you whole information
of that.
The process can't access desFile because it's being used by another
process
There is just some process which is using the file someway. I am not ready
now to say what a process is it and why it holds the file but to be sure
there is one. May be you should remember the clr memory managment and check
out where that file has been accessed in your code. So to drop the object's
reference does not cause its destruction because of clr memory managment and
all resources being using by the object are held. Remeber of IDisposable
interface and its Dispose() method, may be this would be the answer.
"Jason Jacob" <50******@alumni.cityu.edu.hk> wrote in message
news:b8**************************@posting.google.c om... To all,

I've tried to use System.IO.File.Move (srcFile, desFile);
but there is an exception similar to this :
The process can't access desFile because it's being used by another
process

I think that it's strange since I've already closed the FileStreams
associated to all available files already....

Any clues ??

From Jason (Kusanagihk)

Nov 16 '05 #2
Download Process Explorer from

http://www.sysinternals.com

You can use that to find out which process is locking a file. You may find its not your running application but Devenv.exe or something like that.

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<b8**************************@posting.google.com >

To all,

I've tried to use System.IO.File.Move (srcFile, desFile);
but there is an exception similar to this :
The process can't access desFile because it's being used by another
process

I think that it's strange since I've already closed the FileStreams
associated to all available files already....

Any clues ??

From Jason (Kusanagihk)

Nov 16 '05 #3

I've encountered these errors when
- the file already exists in the destination directory (FileCopy
allows an overwrite, but FileMove doesn't)
- different security settings exist on the file to be moved (file
belonging to admin only...)

Regards,

Chris
Nov 16 '05 #4

I've encountered these errors when
- the file already exists in the destination directory (FileCopy
allows an overwrite, but FileMove doesn't)
- different security settings exist on the file to be moved (file
belonging to admin only...)

Regards,

Chris
Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Riyad | last post: by
6 posts views Thread by ASP.Confused | last post: by
reply views Thread by ASP.Confused | last post: by
2 posts views Thread by Loane Sharp | last post: by
2 posts views Thread by =?Utf-8?B?bXVyYWRqYW1lcw==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.