DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   VB.NET (http://www.daniweb.com/forums/forum58.html)
-   -   how to change file name? (http://www.daniweb.com/forums/thread166776.html)

donaldunca Jan 7th, 2009 9:48 am
how to change file name?
 
I'm learning vb.net, I have to work with file and folders.
I need to know how to change file or folder name.
Could you help me?
Thanks for advanced!

rapture Jan 7th, 2009 10:18 am
Re: how to change file name?
 
Sure no problem

 Dim newName As New FileInfo("filename.gif")
 
  newName.MoveTo("filename2.gif")

This should work. You can look at fileinfo.moveto() or file.move() for more information

here is an example

http://www.example-code.com/vbdotnet/rename-file.asp

you can google "vb.net rename file" and get more.

Does that help?

waynespangler Jan 7th, 2009 6:45 pm
Re: how to change file name?
 
vb 2005 and vb 2008:
Quote:

My.Computer.FileSystem.RenameFile("c:\test\test.txt", "c:\test\NewName.txt")


All times are GMT -4. The time now is 9:53 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC