473,401 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Error trying to move file

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
2 2956
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: bmgz | last post by:
I am have made a simple script that moves all desktop clutter (ie files that are not *.lnk) to a specified folder eg. c:\myhome\mydocs\desktopdebris\2003-12-16 ...
2
by: Keith Kowalski | last post by:
I anm opening up a text file reading the lines of the file that refer to a tif image in that file, If the tif image does not exist I need it to send an email stating that the file doesn't exist...
6
by: Patrick Dugan | last post by:
Hello, I'm trying to load different images (icons) into a PictureBox1.Image. The first image loads just fine, but the second image always returns the error "Invalid property used." It doesn't...
7
by: GRoll35 | last post by:
I have 3 files here - Header/Implementation/Driver All it has to do is send the user's input (age)..to the class and the class will figure out the price of the ticket. I'm suppose to create the...
7
by: SKUNKFACEWOODY | last post by:
I hope for the sake of my sanity and the safety of my computer someone can help. I have been trying to install php5 to use with apache2 and windows xp. Apache installs fine and when you look up...
2
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include...
1
wadro21
by: wadro21 | last post by:
i am trying to write a php uploader for a site and keep getting this error: Warning: move_uploaded_file(uploads61877494_tp.jpg) : failed to open stream: Permission denied in...
11
by: Jim in Arizona | last post by:
I've looked around the web but can't find anything to help me out. I was able to get some code to move some files from one directory to another, which works fine: ...
1
by: MC | last post by:
I had 2 folders I couldn't move or delete. Each had contained the executable from a console-mode Visual Studio 2008 C# application. On trying to move the folders I got the entirely misleading UAC...
11
by: xenoix | last post by:
hey there, im reasonably new to C# and im currently writing a backup application which im using as a learning resource. My PC :- Visual Studio 2005 .NET Framework 2 Component Factory Krypton...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.