[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do i rename a file using vb 2005

Posted on 2008-11-13
7
Medium Priority
?
496 Views
Last Modified: 2013-11-25
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
0
Comment
Question by:awolarczuk
7 Comments
 
LVL 7

Expert Comment

by:aherps
ID: 22948706
  Dim fi As New FileInfo("myFile.doc")
   
   fi.MoveTo("myFile2.doc")
0
 
LVL 48

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 1200 total points
ID: 22948732
IO.File.Move("C:\Path\OldFileName.txt", "C:\Path\NewFilename.txt")

Wayne
0
 
LVL 2

Assisted Solution

by:MTEXX
MTEXX earned 800 total points
ID: 22949584
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 48

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 22949641
>>Don't forget the eternal excpetions:

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

Wayne
0
 
LVL 2

Expert Comment

by:MTEXX
ID: 22949836
what about filename collisions, invalid characters, network path access?
always catch those dang exceptions !!
0
 
LVL 48

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 22950217
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
 

Author Comment

by:awolarczuk
ID: 22969143
Hi Wayne this is my question am i didnt make any bad comments mate i thank everyone for there comments

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question