English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i have a Label1.Text that displays a randomly produced number. is there a way to rename a file using Label1.Text as the file name

2007-09-11 09:36:38 · 2 answers · asked by Supreme Overlord 2 in Computers & Internet Programming & Design

2 answers

Let's assume your file is originally named "oldfile.txt" and is on the root of "C:\"

-----

Dim oldFileName As String = "C:\Oldfile.txt"
Dim newFileName As String = Label1.Text

My. Computer. FileSystem. RenameFile (oldFileName, newFileName)

-----

(Of course, you shouldn't put spaces after the dots in that last line. I did, in order to keep Yahoo from truncating the long string, so you could see the whole thing.)

2007-09-11 09:50:39 · answer #1 · answered by Scotty Doesnt Know 7 · 3 0

You need to "move" the file

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

fi.MoveTo("myImage2.gif")

2007-09-11 16:40:30 · answer #2 · answered by Anthony G 1 · 1 1

fedest.com, questions and answers