2013-12-09 31 views
0

連接,如果我嘗試錯誤SMB目錄使用JCIFS

NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("cabanellos.local","deivisson.sedrez", "passs"); 
String path = "smb://fsct/scanpr$/test.txt";` 
SmbFile sFile2 = new SmbFile(path, auth); ` 

它連接,並創建一個文件,但如果我嘗試:

NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("cabanellos.local", "deivisson.sedrez", "passs"); 
String path = "smb://fsct/scanpr$/"; 
SmbFile sFile2 = new SmbFile(path, auth);  
SmbFile[] varTeste = dir.listFiles();  
for(int i=0;i<varTeste.length;i++){ 
    if(varTeste[i].isFile()){          
     //site = new URL((Pasta_Financeiro + varTeste[i].getName()).toString()); 
     SmbFile dest = new SmbFile ("file:///"+Pasta_Financeiro + varTeste[i].getName()); 
     dir.copyTo(dest); 
    } 
} 

我得到這個例外「登錄失敗:用戶名未知或密碼錯誤。「但全部正確

爲什麼會發生這種情況?

回答

0

你或許應該用 「SMB://」 + Pasta_Financeiro而不是 「文件:///」 + Pasta_Financeiro

0

我使用

SmbFile remoteFile = new SmbFile("smb://...") OutputStream os = new FileOutputStream("/path/to/local/file"); InputStream is = remoteFile.getInputStream(); int bufferSize = 1024; byte[] b = new byte[bufferSize]; int noOfBytes = 0; while((noOfBytes = is.read(b)) != -1) { os.write(b, 0, noOfBytes); } os.close(); is.close();

dir.copyTo(dest);

及其作品

求助

TY