How do i rename a file using vb 2005

Hi all i am wanting to rename a file after it has been copied, i have already got the copied to copy it i just need to rename is now

Thanks in advance
awolarczukAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aherpsCommented:
  Dim fi As New FileInfo("myFile.doc")
   
   fi.MoveTo("myFile2.doc")
0
Wayne Taylor (webtubbs)Commented:
IO.File.Move("C:\Path\OldFileName.txt", "C:\Path\NewFilename.txt")

Wayne
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MTEXXCommented:
Don't forget the eternal excpetions:


Dim prevFilespec As String = "C:\temp\foofie.txt"
Dim newFilespec As String = "C:\temp\foofieXYZ.log"
Try
    System.IO.File.Move(prevFilespec, newFilespec)
Catch ex As Exception
    Console.WriteLine("caught exception: " + ex.ToString)
End Try

Open in new window

0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Wayne Taylor (webtubbs)Commented:
>>Don't forget the eternal excpetions:

One would assume the file path was validated before performing a rename action.

Wayne
0
MTEXXCommented:
what about filename collisions, invalid characters, network path access?
always catch those dang exceptions !!
0
Wayne Taylor (webtubbs)Commented:
That may be the case, but please show some respect and acknowledge other Experts when you use their solutions.

http://www.experts-exchange.com/help.jsp#hi416

Wayne
0
awolarczukAuthor Commented:
Hi Wayne this is my question am i didnt make any bad comments mate i thank everyone for there comments

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.