6

While running the below code i am getting the exception

jcifs.smb.SmbException: The system cannot find the file specified

Code:

public void m1(String b) throws IOException {
        // TODO Auto-generated method**strong text** stub

        BufferedReader br=null;
        String urlToBackUpFile = "smb://" +b +"/" + "c$/Program Files/Office/Config/OfficeSyncData.ini";
        String cp="smb://" +b +"/" + "c$/Program Files/Office/Config/OfficeSyncData.txt";
        System.out.println("smb folder of source file" + urlToBackUpFile);
        NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null, "usrname", "passwd");


          SmbFile dir = new SmbFile(cp, auth);
          SmbFileInputStream in = new SmbFileInputStream( dir );
         // br = new BufferedReader(new InputStreamReader(in));


          System.out.println(dir.getDate());
          SmbFile dest = new SmbFile (urlToBackUpFile,auth);
          //count.copyTo(dest);
          dir.copyTo(dest);

    }

How do i resolve?.

sTg
  • 4,313
  • 16
  • 68
  • 115
Kishore kumar
  • 81
  • 1
  • 6

1 Answers1

1

Without the entire stack trace I cannot be completely sure, but you may need to specify in the path the escape space character.

Try this:

String urlToBackUpFile = "smb://" +b +"/" + "c$/Program\\ Files/Office/Config/OfficeSyncData.ini";

And make sure that if "b" contains a space you do the same.

EDITED: also to try: can you point the path to a location that doesn't contain any spaces? that would prove if the space syntax is the source of your problems...

gmcontessa
  • 558
  • 4
  • 10
  • You'd need at least two ` \ ` if you want to escape it that way, i.e. `program\\ files`. Not saying it will help though. – geert3 Oct 04 '15 at 18:45
  • sorry, edited the code to include the double '\' . Maybe worth a try anyway as the shell language of linux terminals (even when emulated in windows) need the space escaping – gmcontessa Oct 04 '15 at 18:57