Jcifs.smb.SmbException: the system cannot find the specified file?

When running the code below, I get an exception

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

The 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 can I decide?

+5
source share
1 answer

Without all the stack tracing, I cannot be completely sure, but you may need to specify a path character in the path.

Try the following:

 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 try: can you provide a path to a location that does not contain spaces? to prove that spatial syntax is the source of your problems ...

+1
source

All Articles