[RESOLVED] Rename file using label caption?
I need some help with this one, so I hope someone could help me out :thumb:
I'll try and keep this simple:
I'm reading from a file and extracting 3 strings from the file (abc.txt) and placing them into 3 seperate label captions.
Example:
Label1.Caption = "the cat" (strLine1)
Label2.Caption = "sat on" (strLine2)
Label3.Caption = "the mat" (strLine3)
I then want to rename the same file (abc.txt) that was opened using common dialog to (the cat_sat on_the mat.txt)
Hope someone wiil help this poor newb ;)
Re: Rename file using label caption?
To rename a file you can use 'Name filename As new filename'
VB Code:
Name "C:\abc.txt" As "C:\" & Label1.Caption & "_" & Label2.Caption & "_" & Label3.Caption & ".txt"
casey.
Re: Rename file using label caption?
Thanks for your help casey,
Can I apply your suggestion if I am intending to use a common dialog to open the file (therefore file can be situated anywhere) and then allow the user to click a simple command button to rename the file?
Also, Am I correct in my thinking that renaming a file is also overwriting the existing file?
Thanks,
Jon.
Re: Rename file using label caption?
Yes. you can use that.
And also,
If you get an answer, please resolve the thread using Thread tools mark thread resolved.
Re: Rename file using label caption?
Thanks, I'll try it again then. I would've resolved earlier if I knew it was resolved.
Re: Rename file using label caption?
Quote:
Originally Posted by Jon101
Also, Am I correct in my thinking that renaming a file is also overwriting the existing file?
No, you're not. Overwriting the file destroys all the data in the file at the time it's overwritten. Renaming it merely changes the name, but leaves the contents intact.