File.Move File.Delete 
Author Message
 File.Move File.Delete

I am having problems implementing a process that moves or deletes a file (I
have been able to make the copy process work).

Every time I implement the File.Move(filename) or File.Delete(filename), I
get an exception that states:
The process cannot access the file filename because it is being used by
another process.

Any idea how I can make this work?

(additional information:  The file I am trying to move or delete is an image
file that is displayed in a picture box.  I have tried resetting the image
to a different file prior to the delete or move process, but I still get the
same message.)

Thanks for any assistance...

Matt



Fri, 13 Aug 2004 09:15:55 GMT  
 File.Move File.Delete
Matthew,

    You probably are not calling Dispose on the original image (which you
probably get with the static FromFile method on the Image class), which is
causing you to keep a hold on the file.  Get the Image before you set it to
something else, calling the Dispose method on the image.  You should then be
able to delete it.

    If that doesn't work, before you load your image into the picturebox,
try cloning the image (using the Clone method) and assigning the clone to
the imagebox.

    Hope this helps.

--
                    - Nicholas Paldino [.NET MVP]


Quote:
> I am having problems implementing a process that moves or deletes a file
(I
> have been able to make the copy process work).

> Every time I implement the File.Move(filename) or File.Delete(filename), I
> get an exception that states:
> The process cannot access the file filename because it is being used by
> another process.

> Any idea how I can make this work?

> (additional information:  The file I am trying to move or delete is an
image
> file that is displayed in a picture box.  I have tried resetting the image
> to a different file prior to the delete or move process, but I still get
the
> same message.)

> Thanks for any assistance...

> Matt



Fri, 13 Aug 2004 10:59:20 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Help needed:File copying, deleting or moving

2. HOWTO: Deal with Files -- Move, Copy, Delete

3. Move files to Recycle Bin and drag files to explorer

4. HELP : Deleting bytes from binary file, using FILE *

5. lost (deleted??) file in my workspace file

6. File.Move() bug

7. moving files into web application

8. Moving files to the Recycle Bin

9. How to programmatically set ID/pwd for file.move

10. moving the file pointer beyond EOF

11. Moving within a file

12. moving en copying files in C?

 

 
Powered by phpBB® Forum Software