How do you move files around using VB.net ?

  • Thread starter Thread starter Rob
  • Start date Start date
R

Rob

I need to move some files to different folders. How would you do it within
compact framework ? File system object work here ?

Thanks
 
There is no FSO in CE, and in VB.NET on the desktop it's still the wrong way
to go. Look at the System.IO namespace. File.Move is probably what you're
after.

-Chris
 
I simply want to copy a file....

str1 = \\My Device\My Documents\Folder1\orders.xml"

to

str2 = \\My Device\Program Files\Folder2\orders.xml"

File.Copy (str1,str2)

But I get an exception error that disappears faster than I can read it...

Thanks !
 
Hi
Please try changing as below:

str1 ="\My Device\My Documents\Folder1\orders.xml"
str2 = "\My Device\Program Files\Folder2\orders.xml"
File.Copy (str1,str2)

As we reference path starting with single slash and your code shows
double slashes.
Also please take care that Folder1 and Folder2 exists in respective
paths.

Regards,
Bipin Kesharwani
(Developer)

Palewar Techno Solutions
Pocket PC & Mobile Software Development
Nagpur, India

http://www.palewar.com
 
Thanks, but that is still not working....

I added code to test for file exists... I am absolutely sure that the file
DOES exist. Could there be a problem with the spaces between the words "My
Device" etc. ?

Any other suggestions ?
 
You cannot copy from the device to the desktop like this. I've answered
this in your other post of the same question (which is bad form I might
add).

-Chris
 
No, this is all done on the handheld 100%....


You cannot copy from the device to the desktop like this. I've answered
this in your other post of the same question (which is bad form I might
add).

-Chris
 
Chris,

Here is the code I am running All of which is on the handheld.... there is
no copy to or from the Desktop invlolved. (That was an earlier and
different question.)

When I use File Explorer on the handheld I know that the files do exist on
the handheld, yet I get the "File NO Exists" error.



strFilePathOrdersBOD = "\My Device\My
Documents\ZSampleApp\ToHandheld\Orders.xml"

strFIlePathOrdersLive = "\My Device\Program Files\ZTest1\Orders.xml"

If File.Exists(strFilePathOrdersBOD) Then

MsgBox(strFilePathOrdersBOD & " - File Exists")

Else

MsgBox(strFilePathOrdersBOD & " - File NO Exists")

End If

If File.Exists(strFIlePathOrdersLive) Then

MsgBox(strFIlePathOrdersLive & " - File Exists")

Else

MsgBox(strFIlePathOrdersLive & " - File NO Exists")

End If
 
"\My Device" should be removed then.

-Chris


Rob said:
Chris,

Here is the code I am running All of which is on the handheld.... there is
no copy to or from the Desktop invlolved. (That was an earlier and
different question.)

When I use File Explorer on the handheld I know that the files do exist on
the handheld, yet I get the "File NO Exists" error.



strFilePathOrdersBOD = "\My Device\My
Documents\ZSampleApp\ToHandheld\Orders.xml"

strFIlePathOrdersLive = "\My Device\Program Files\ZTest1\Orders.xml"

If File.Exists(strFilePathOrdersBOD) Then

MsgBox(strFilePathOrdersBOD & " - File Exists")

Else

MsgBox(strFilePathOrdersBOD & " - File NO Exists")

End If

If File.Exists(strFIlePathOrdersLive) Then

MsgBox(strFIlePathOrdersLive & " - File Exists")

Else

MsgBox(strFIlePathOrdersLive & " - File NO Exists")

End If
 
Back
Top