-3

I need to create a directory in another PC using Java, so I used FILE class,
my code structure is

    String path = "\\\\192.148.64.99"+File.separator+"D:"+File.separator+"hello";          

    String fname= path+File.separator+"Sample.pdf";
    File file = new File(fname);
    System.out.println("Exists"+file.exists());
    file.getParentFile().mkdirs();   

This throwing error.

halfer
  • 19,824
  • 17
  • 99
  • 186
Sajini
  • 45
  • 1
  • 1
  • 8
  • 3
    What error ? Please post the Exception stacktrace.You can't access files on other people's machines unless they have published some sort of file share – AllTooSir Jul 11 '13 at 08:21
  • 1
    Do you know that one, in general, doesn't have access to the entire file system on another machine? You need to share specific folders and you have access to these. Trying to simply specify the drive (which I presume is what `D:` is) probably won't work. Not to mention that `:` probably isn't a valid character for a (network) path either. Try opening the desired path (i.e. `\\192.148.64.99\D:\hello`) in your OS first and see if it works. If not, you probably need to work through a tutorial in basic (Windows?) file sharing. – Bernhard Barker Jul 11 '13 at 08:25
  • 1
    `\\192.148.64.99\D:\hello` isn't a valid path, in any bodies book – MadProgrammer Jul 11 '13 at 08:26
  • Then how to proceed with this, My requirement is to create a folder structure in remote pc – Sajini Jul 11 '13 at 08:34

1 Answers1

0

D: in the path you are constructing is not valid. You could use D$ instead if you are admin on the remote machine. Path should be \\MachineName\ShareName\Folder\SubFolder...

Tarik
  • 10,810
  • 2
  • 26
  • 40