![]() |
copying files
Ok so i'm trying to copy a file from one folder to another and i'm running into a problem. currently i know that in order to copy something you use the File.Copy( , ) method (assuming you import system.io.*) problem being the dest file can't be an exsisting file or directory. fine. I used a a loop to pull the file up and then tried the copy method. now my problem being that i'm getting a full path extension and not just a file name. Any one know how to cut the file name path apart without knowing how long the file is or it's name?
ie :
dim user as stringproblem i'm having is that myFile(i) where the comment is, i actually the value "C:\tmp\testing.doc" and the two paths are colliding. I need to get the myFile(i) to be just testing.doc The only thing i can think of is indexOfLast? but doesn't that return an integer? |
there are several ways to do this, here is one.
:
|
This is pretty much identical to yours with only a slight difference; but try it, it should work. I dont have .net right here so I cant test it for you.
:
Dim user as String = _ |
Alright so i tried it and at first i got it to work within the same folder (searching c:\tmp for whatever i needed) then when i knew it work i changed it so that it wouls search all of C:\ as oppsed to just C:\tmp....now it doesn't work here is what i have:
:
dim user as string where i have the comment that's the only line i've changed where the program stops working as intended i went from C:\tmp to C:\ and it doesn't find anyfiles. |
:
Dim user As String = System.Environment.Username.ToString()Try that. I have never used this method before and have just written it, unfortunately I am not at a PC with VS so this is untested. |
Not to bring up an old post, but I was digging around and searching for Copy method and directory searching method. I noticed on the previous codes there is a statement as such:
:
Dim files As String() = Directory.GetFiles("C:\","*.doc", SearchOption.AllDirectories |
As long as you can honestly assure me you are not blind then I guess it is safe to say the parameter is not there. But wether this has to do with your version being 2003 im not sure, my presumption is that it is the version of the framework you are using that matters. Although 2003 would come packaged with .NET1.1 an upgrade to .NET2.0 would be recognised by your IDE I beleive, though this is another presumption.
So maybe its just a newer version of the framework that you need...? |
Quote:
|
Yep, seems our company is still running 1.0 framework. That stinks. This app need to run on more computers then my own. I guess I have to live w/o that option, damnit.
|
| All times are GMT -5. The time now is 1:14 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC