[RESOLVED] [02/03] Rename file successful?
Hello,
I found a function called Rename, just simply Rename, that renames a file. It works, but is it bad to use that? Usually that seems to be the case with functions that aren't part of a namespace. Also, the user tries to rename a file to "////a//aa//" it will rename it to "aaa". I was hoping to have it do a literal renaming, which would break in that case, which I would handle.
So, does anyone know of a better way to do renaming in 2003? The examples I found were in 2005.
Re: [02/03] Rename file successful?
This works in VB2005:
My.Computer.FileSystem.RenameFile("C:\OldFilename.txt", "NewFilename.txt")
Not sure if it works in 2003.
Re: [02/03] Rename file successful?
Quote:
Originally Posted by nbrege
This works in VB2005:
My.Computer.FileSystem.RenameFile("C:\OldFilename.txt", "NewFilename.txt")
Not sure if it works in 2003.
That wont work in 2003, the My namespace doesnt exist.
Re: [02/03] Rename file successful?
That is what I found in the 2005 posts. Unfortunately, there is no My namespace in 2003.
Re: [02/03] Rename file successful?
Possibly, you could move, not rename the files. They do similar things.
IO.File.Move(oldFileName, newFileName) may work
Re: [02/03] Rename file successful?
I think that will work computafreak. I was using copy and delete, and I thought about using move, but then I came across rename. Anyway, I got caught up in other problems with renaming and forgot about trying Move. Thanks.