renameTo() not working remotely
I'm using the file.renameTo() method to rename files remotely.
This code works:
Code:
File f1 = new File("C:\\hi.txt");
File f2 = new File("C:\\hi2.txt");
f1.renameTo(f2);
This code does NOT work.
Code:
File f1 = new File("\\\\computer\\C:\\hi.txt");
File f2 = new File("\\\\computer\\C:\\hi2.txt");
f1.renameTo(f2);
Also. It is not a permissions issue because I have tested this with the local computer name and it doesn't work. Maybe it has something to do with the formatting of the paths?
Doesn't work:
Code:
File f1 = new File("\\\\localcomputer\\C:\\hi.txt");
File f2 = new File("\\\\localcomputer\\C:\\hi2.txt");
f1.renameTo(f2);
No errors are returned. Much help would be appreciated, or perhaps an alternative to renameTo() that would allow me to rename files remotely.
I don't really trust the copy and then delete method... especially when working with really important files.
Thank you!
Re: renameTo() not working remotely
I solved it.
The correct answer is this:
Code:
File f1 = new File("\\\\localcomputer\\C$\\hi.txt");
File f2 = new File("\\\\localcomputer\\C$\\hi2.txt");
f1.renameTo(f2);
C$ rather than C: