Results 1 to 2 of 2
  1. #1
    PrinceSendai is offline Member
    Join Date
    Jul 2010
    Location
    Lima, Peru
    Posts
    47
    Rep Power
    0

    Question renameTo() not working remotely

    I'm using the file.renameTo() method to rename files remotely.

    This code works:

    Java Code:
    File f1 = new File("C:\\hi.txt");
    File f2 = new File("C:\\hi2.txt");
    f1.renameTo(f2);

    This code does NOT work.


    Java 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:

    Java 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!

  2. #2
    PrinceSendai is offline Member
    Join Date
    Jul 2010
    Location
    Lima, Peru
    Posts
    47
    Rep Power
    0

    Default Re: renameTo() not working remotely

    I solved it.


    The correct answer is this:

    Java Code:
    File f1 = new File("\\\\localcomputer\\C$\\hi.txt");
    File f2 = new File("\\\\localcomputer\\C$\\hi2.txt");
    f1.renameTo(f2);

    C$ rather than C:

Similar Threads

  1. How can client gain access to my RMI server remotely?
    By ChexWithRaisins in forum Networking
    Replies: 16
    Last Post: 01-07-2012, 11:15 AM
  2. f.delete() and f.renameTo() does not work
    By doobybug in forum New To Java
    Replies: 6
    Last Post: 08-09-2011, 12:48 AM
  3. Disk Space Checker for Windows and Linux remotely.
    By itsnexgen in forum New To Java
    Replies: 3
    Last Post: 06-14-2011, 12:27 PM
  4. remotely access video stream from camera
    By adityapr in forum Networking
    Replies: 1
    Last Post: 05-03-2011, 11:07 PM
  5. Question about File renameTo() method : Abnormal output
    By suvojit168 in forum New To Java
    Replies: 1
    Last Post: 07-25-2009, 09:22 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •