Reputation: 81
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?.
Upvotes: 6
Views: 8052
Reputation: 558
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...
Upvotes: 1