|
-
Feb 8th, 2011, 07:43 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Moving Files Problem
Hi ALL,
I'm using C#4.0
When I try to run the following :
Code:
File.Move(@file, @ConfigurationManager.AppSettings["CompletedFolder"]);
I receive the error:
Cannot create a file when that file already exists.
However the files do not exist in the destination folder.
Any ideas?
-
Feb 8th, 2011, 09:01 AM
#2
Re: Moving Files Problem
Assuming you have double checked everything I would hazard a guess that the command expects a full path for the destination (or perhaps a destination terminated with a backslash). I think it is currently interpreting the destination folder as the new name for the file.
-
Feb 8th, 2011, 09:15 AM
#3
Thread Starter
Fanatic Member
Re: Moving Files Problem
Yes, You are right, it wasn't enough for me to just give a destination folder. I needed to give it the name of the file as well.......
Code:
foreach (string @file in workLockton)
{
String[] fileName = file.Split('\\');
File.Move(@file, @ConfigurationManager.AppSettings["CompletedFolder"] + "\\" + fileName.Last());
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|