rename file

JoK
10-09-2001, 05:55 AM
i want to rename a file (path contains dirs with names longer than 8 characters). i used Name oldName$ As newName$.
vb made a copy (!) of the file, and even when i reloaded the explorer window, the old file wasn't gone!
I tried shell("ren " & oldName$ & " " & newName$) which didn't work (i guess vb uses the same dos command internally).
when i tried to copy the file and kill the old one afterwards, the kill command failed (file not found)!

(I tried those things out in test mode (F5 key) and didn't compile my app yet, if this is of any importance)

What should i do?!

Banjo
10-09-2001, 06:04 AM
Make sure that you specify a full path for the destination.
E.g.:
<pre>Name "c:\Hello.txt" As "Hello.bak"</pre>
will move the file into App.path. What you need is:
<pre>Name "c:\Hello.txt" As "c:\Hello.bak"</pre>

JoK
10-09-2001, 06:11 AM
i know that and i did so!
thanx, though

Banjo
10-09-2001, 06:18 AM
Don't know then. The only thing I can suggest is to step through the code in break mode and make sure the oldName and newName variables contain the correct filenames.

JoK
10-09-2001, 06:40 AM
i did! i'm goin crazy!

Banjo
10-09-2001, 06:45 AM
Could you post the code and the file that you're trying to rename (if it's not too big)?

JoK
10-09-2001, 06:50 AM
i'll try to do later but i've internet only at school! :)

Squirm
10-09-2001, 08:26 AM
Don't use Name and then Kill, use FileCopy then Kill, like so:

<pre>FileCopy "C:\Program Files\SomeDirectory\SomeSubDir\AFile.txt", "C:\AFile.txt"
Kill "C:\Program Files\SomeDirectory\SomeSubDir\AFile.txt"</pre>

good luck...... images/icons/wink.gif

Thinker
10-09-2001, 12:18 PM
I am not sure if this applies to the Name statement, but if you are
shelling a REN command with long file names, you have to have the
paths/names enclosed in quotes. Something like...
<pre>
Shell("ren """ & oldName$ & """ """ & newName$ & """")


</pre>

I think therefore I am... sometimes right. images/icons/wink.gif

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum