473,385 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Renaming files

Hi

How can I rename a file on disk in vb,net? Basically I am looking for vb.net
equivalent of the vba Name command.

Thanks

Regards
Mar 25 '08 #1
3 1331
My.Computer.Filesystem.RenameFile
or

' How to move / rename a file.
Private Sub button6_Click(sender As Object, e As System.EventArgs)

Dim fi As New FileInfo("myImage.gif")

fi.MoveTo("myImage2.gif")

End Sub 'button6_Click


"John" <in**@nospam.infovis.co.ukwrote in message
news:u9**************@TK2MSFTNGP05.phx.gbl...
Hi

How can I rename a file on disk in vb,net? Basically I am looking for
vb.net equivalent of the vba Name command.

Thanks

Regards

Mar 25 '08 #2
On Mar 25, 4:11 am, "John" <i...@nospam.infovis.co.ukwrote:
Hi

How can I rename a file on disk in vb,net? Basically I am looking for vb.net
equivalent of the vba Name command.

Thanks

Regards
An alternative way:

' Specify file that you want to rename
Dim file As New System.IO.FileInfo("c:\test.txt")

' Copy current file with a new file name
file.CopyTo("c:\new_test.txt")

' Delete old file
file.Delete()

but i think "My" namespace is much easy-to-use.
Mar 25 '08 #3
"John" <in**@nospam.infovis.co.ukschrieb:
How can I rename a file on disk in vb,net? Basically I am looking for
vb.net equivalent of the vba Name command.
Take a look at these functions/methods:

'Rename'
'My.Computer.FileSystem.RenameFile'
'My.Computer.FileSystem.RenameDirectory'
'File.Move'
'Directory.Move'

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Mar 25 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: MikeY | last post by:
Hopefully someone can help, I have a listview box where I display my desired files. I single click on the desired file to be renamed and I rename it with a new name. My problem arises when the...
16
by: dudufigueiredo | last post by:
I have one folder containing mp3 files, the folder is: C:\My Shared Folder\Rubber Soul And the files are: 01 drive my car.mp3 02 norwegian wood.mp3 03 you won't see me.mp3 04 nowhere man.mp3...
1
by: Don Leverton | last post by:
Hi Folks, I have been given a CD with approx 130 .xls files (bean-counters!) that I would like to import and merge to ONE table (tblTradeshow). The XL files are *similarly*, but not...
3
by: Colin | last post by:
I have two files and I want to rename file B to file A without doing a system call - can I do this in C using file pointers ?
6
by: Pegboy | last post by:
I am trying to create a DOS utility that will extract data from a file and use it to form a new filename for that same file. I can successfully open the file, get the data I need and form the new...
1
by: MikeY | last post by:
Hopefully someone can help, I have a listview box where I display my desired files. I single click on the desired file to be renamed and I rename it with a new name. My problem arises when the...
1
by: farseer | last post by:
HI, i have created a DataSet using the DataSet Designer. The default name is DataSet1. I then renamed this to "MyDataSet" and proceed to add my TableAdapters using the Visual Designer. After i...
1
by: Jack Maxwell | last post by:
Hope someone can help here. My brother has asked me if I can assist in renaming about 1500 midi files which are associated with a programm called Cubase SE. With that software installed he can...
1
by: GeoDW | last post by:
Hell All, I have looked around and not found the solution I am looking for within the old threads. Here is my problem: I have a directory full of .img and .rrd files that have long filenames...
2
by: Alan Mailer | last post by:
I am relatively new to VB.net. I want to change the name of a Project and change the name of the files in the Project's various folders to reflect that new project name. Is there something I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.