By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,593 Members | 2,006 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,593 IT Pros & Developers. It's quick & easy.

rename the filename thru vb

P: 11
hi everybody,

iam using the following code for open the file.

sfil = d:\abc.txt

nSourceFile = FreeFile
Open sfil For Input As #nSourceFile

now i want 2 change the extension of the opened file to .bak. ie the original file wants 2 rename.



can any one help me regarding this isssue

regards

vivek
Nov 8 '06 #1
Share this Question
Share on Google+
5 Replies


100+
P: 1,646
hi everybody,

iam using the following code for open the file.

sfil = d:\abc.txt

nSourceFile = FreeFile
Open sfil For Input As #nSourceFile

now i want 2 change the extension of the opened file to .bak. ie the original file wants 2 rename.



can any one help me regarding this isssue

regards

vivek
If you take a look at the file object which is part of the filesystemobject collection you will see that you can change the filename
Nov 8 '06 #2

P: 4
Name old name and path As new name and path
hope this helps
Nov 8 '06 #3

P: 1
That doesn't work with files that need to be overwritten.
An error saying that the file already exists pops up.
Feb 11 '07 #4

Expert 5K+
P: 8,434
That doesn't work with files that need to be overwritten.
An error saying that the file already exists pops up.
Perhaps so, but that wasn't part of the original question.

Also, it's worth noting that while statements such as Name As are quick and simple to code, the FileSystem Object gives you much more power and control over the file system.
Feb 12 '07 #5

balid
P: 18
Perhaps so, but that wasn't part of the original question.

Also, it's worth noting that while statements such as Name As are quick and simple to code, the FileSystem Object gives you much more power and control over the file system.

Plus you can override the warning message this way as well.
Feb 12 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.