Connection Not Closing File.Move
-
Hi. I'm using the "File.Move" method in the System.IO namespace. When I start my program and call this method it executes no problem. The second time I call it I am getting and error message saying "Exception: The process cannot access the file ... because it is being used by another process". When I close the program and run it again the method runs fine, again for the first time. I would think the connection is just not closing for some reason. Does anyone know how I can fix this?
-
Hi. I'm using the "File.Move" method in the System.IO namespace. When I start my program and call this method it executes no problem. The second time I call it I am getting and error message saying "Exception: The process cannot access the file ... because it is being used by another process". When I close the program and run it again the method runs fine, again for the first time. I would think the connection is just not closing for some reason. Does anyone know how I can fix this?
Well, you could try calling dispose() on your object to see if it would help. My guess is your problem is somewhere else. Are you using any FileStreams ? You definately need to close those by explicitly calling Close() on them. Post some more code if you can... -Peter
-
Hi. I'm using the "File.Move" method in the System.IO namespace. When I start my program and call this method it executes no problem. The second time I call it I am getting and error message saying "Exception: The process cannot access the file ... because it is being used by another process". When I close the program and run it again the method runs fine, again for the first time. I would think the connection is just not closing for some reason. Does anyone know how I can fix this?
Not enough information. Move what file? Is your application writing it? Are you holding it open? Where does this file come from that your trying to move? The problem is obvious - "being used by another process". This means that you can't move a file that is open for reading and/or writing. So what has the file open? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome