System.IO.File.Move

  • Thread starter Thread starter Daniel
  • Start date Start date
D

Daniel

why does System.IO.File.Move("c:\\hmbug.jpg", "c:\\foodoo\\foo.jpg"); throw
access denied? im just moving a file in a console app? any ideas?
 
Hi Daniel,

Does the destination file already exist? Is some other program accessing hmbug.jpg (might well be one of your own previous compilation which is still running).

If the target file already exists you need to delete it first.

if(File.Exists("c:\\foodoo\\foo.jpg"))
File.Delete("c:\\foodoo\\foo.jpg");
 
Make sure that the directory foodoo exists and you have write permission
in the directory. Another reason could be that the file hmbug.jpg is
locked by some process or your own process and hence cannot be moved.
Try moving the file from windows explorer while your app is running.

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

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

Back
Top