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

Error trying to move file

P: n/a
My VB call:
System.IO.File.Move("C:\CDRs\Suntera\Pending\08012 0040004.txt",
"C:\CDRs\Suntera\Loaded\")

Generates an exception:
'System.IO.IOException' occurred in mscorlib.dll
Additional information: Cannot create a file when that file already
exists.

However, that file does not already exist in the Loaded directory. In
fact, that directory is empty.

I know the solution to this is probably simple, but I can't figure it
out. Any ideas?

Thanks.
Jeff
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
That is because in the destination file name, you only have the directory
you want to put the file in. Not the full path of the new file (including
actual filename). It seems like you are assuming that the name of the
source file will be used, but the API is such that this doesn't have to be
the case.

"Jeff Wilson" <jw*********@attbi.com> wrote in message
news:fc**************************@posting.google.c om...
My VB call:
System.IO.File.Move("C:\CDRs\Suntera\Pending\08012 0040004.txt",
"C:\CDRs\Suntera\Loaded\")

Generates an exception:
'System.IO.IOException' occurred in mscorlib.dll
Additional information: Cannot create a file when that file already
exists.

However, that file does not already exist in the Loaded directory. In
fact, that directory is empty.

I know the solution to this is probably simple, but I can't figure it
out. Any ideas?

Thanks.
Jeff

Nov 21 '05 #2

P: n/a
Jeff,

* jw*********@attbi.com (Jeff Wilson) scripsit:
My VB call:
System.IO.File.Move("C:\CDRs\Suntera\Pending\08012 0040004.txt",
"C:\CDRs\Suntera\Loaded\")

Generates an exception:
'System.IO.IOException' occurred in mscorlib.dll
Additional information: Cannot create a file when that file already
exists.

However, that file does not already exist in the Loaded directory. In
fact, that directory is empty.


Try something like that:

\\\
Dim FileName As String = "C:\foo\goo.txt"
System.IO.File.Move(FileName, System.IO.Path.Combine("C:\bar", System.IO.Path.GetFileName(FileName)))
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.