Click to See Complete Forum and Search --> : How to rename a file?


February 4th, 2000, 07:43 AM
Hello,

I would want to know how to rename a file.

Thank you for your responses
best regards
philippe gendreau

JimmyT
February 4th, 2000, 07:58 AM
If the file is one that you are renaming using VB, the syntax is

[vbcode]

Name oldname as newname

[\vbcode\

Just be sure to include the complete path in the oldname and newname values.

Example:

[vbcode]

Name "C:\My Documents\JunkDrawer.dat" as "C:\My Documents\UsefulStuff.dat"

[\vbcode]

Good luck...

PGendreau
February 4th, 2000, 09:45 AM
hello,

thank you for your response.

But i want to rename a file with a instruction like "kill FileName"
A instrucction like "Rename Filename"

best regards
philippe gendreau

Nick A.
February 4th, 2000, 09:51 AM
What do you mean? When you rename a file, you must provide both the old and the new filename. There is no other way. JimmyT's suggestion is the only one. Unless the new filename is always constant. If that's the case, you can create a function in which you pass the old filename only as a parameter and it renames it to the constant. Is that what you want?

February 4th, 2000, 10:03 AM
Hello,

Sorry i don't understand the response.
this is what i know to do:

'close the file
Close #1

'open the file
Open sPathModele For Input As #1

'remove the file
Kill sPathModele

and what i don't know
'rename the file ?????????



thank your for your responses (sorry for my poor english)

best regards
Philippe gendreau

Nick A.
February 4th, 2000, 10:13 AM
Now i think i understand what you want.

You must give the filename of the file you want to rename like JimmyT said.

Name "C:\My Documents\OldFileName" as "C:\My Documents\NewFileName"



Kill works the same way:

Kill "C:\My Documents\MyFile"



You cannot do the following:

dim sPathModele as Integer
Open sPathModele for input as #1
Kill sPathModele



It is wrong.

February 4th, 2000, 10:44 AM
Ok Name works great
thanks