By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,709 Members | 2,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,709 IT Pros & Developers. It's quick & easy.

File.Copy problem

P: n/a
I'm getting an exception when trying to copy a file.

I basically do a File.Copy(source, dest, false);

source is the source full path and filename. dest is the destination full
path and filename.

The file actually appears to copy just fine. The problem is it throws an
IOException with the message:

Could not find a part of the path "path\filename."

Where path\filename is the destination full path and filename just as it was
passed to File.Copy.

The destination file does not exist prior to the copy, but it does after the
copy despite the exception. The exception is thrown regardless of whether
the last parameter is true or false.

Anyone know what's causing this?

BTW, source and dest are the local drive. This is a Windows.Forms app. There
shouldn't be any file permission issues.

Pete
Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Sorry, my bad. Finally found it. There was an extra \ in there. Just hard to
see in the debugger.

"Pete Davis" <pdavis68@[nospam]hotmail.com> wrote in message
news:Kp********************@giganews.com...
I'm getting an exception when trying to copy a file.

I basically do a File.Copy(source, dest, false);

source is the source full path and filename. dest is the destination full
path and filename.

The file actually appears to copy just fine. The problem is it throws an
IOException with the message:

Could not find a part of the path "path\filename."

Where path\filename is the destination full path and filename just as it
was passed to File.Copy.

The destination file does not exist prior to the copy, but it does after
the copy despite the exception. The exception is thrown regardless of
whether the last parameter is true or false.

Anyone know what's causing this?

BTW, source and dest are the local drive. This is a Windows.Forms app.
There shouldn't be any file permission issues.

Pete

Nov 17 '05 #2

P: n/a
Pete,

Are you sure the inputs are correct, in the sense that the source and
destination are correct?

Can you reproduce the problem in a short example and post it?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Pete Davis" <pdavis68@[nospam]hotmail.com> wrote in message
news:Kp********************@giganews.com...
I'm getting an exception when trying to copy a file.

I basically do a File.Copy(source, dest, false);

source is the source full path and filename. dest is the destination full
path and filename.

The file actually appears to copy just fine. The problem is it throws an
IOException with the message:

Could not find a part of the path "path\filename."

Where path\filename is the destination full path and filename just as it
was passed to File.Copy.

The destination file does not exist prior to the copy, but it does after
the copy despite the exception. The exception is thrown regardless of
whether the last parameter is true or false.

Anyone know what's causing this?

BTW, source and dest are the local drive. This is a Windows.Forms app.
There shouldn't be any file permission issues.

Pete

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.