简体   繁体   中英

Rename a file at runtime with vb.net

i try to rename a file using vb.net in this way:

my.computer.filesyste.rename(oldname,newname)

But if i use a software to recover files deleted, i find a file named :"_ldname", and if i recovery the file "_ldname" i have, in this way, two files equals. Can i do this without have a duplicate of my file?

Best regards Sebastiano

You cannot, this is a windows filesystem limitation and nothing to do with programming. Two files cannot have the same name in the same location.

The recovery software should be forcing a rename to Myfile(1).txt or something like that to distinguish between the two files.

You could always use:

If File.Exists(path) = False Then 

To make sure the file doesn't already exists. Then if it does exist you could add a "(1)" to the file name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM