Probleme beim Schreiben bei der Datei mit SMBJJava

Java-Forum
Anonymous
 Probleme beim Schreiben bei der Datei mit SMBJ

Post by Anonymous »

Bitte helfen Sie. Ich kann mit SMBJ keine Datei erstellen und in eine Datei schreiben. Ich erhalte diesen Fehler: < /p>

Code: Select all

com.hierynomus.mssmb2.SMBApiException: STATUS_OBJECT_NAME_NOT_FOUND (0xc0000034): Create failed for 
< /code>

Ist dies ein Windows -Fehler oder ein SMBJ -Fehler? Verwende ich die SMBJ -API richtig? Ich verstehe Windows -Dateiattribute /Optionen nicht gut. < /P>

String fileName ="EricTestFile.txt";
String fileContents = "Mary had a little lamb.";

SMBClient client = new SMBClient();
try (Connection connection = client.connect(serverName)) {
AuthenticationContext ac = new AuthenticationContext(username, password.toCharArray(), domain);
Session session = connection.authenticate(ac);

// Connect to Share
try (DiskShare share = (DiskShare) session.connectShare(sharename)) {
for (FileIdBothDirectoryInformation f : share.list(folderName, "*.*")) {
System.out.println("File : " + f.getFileName());
}

//share.openFile(path, accessMask, attributes, shareAccesses, createDisposition, createOptions)
Set fileAttributes = new HashSet();
fileAttributes.add(FileAttributes.FILE_ATTRIBUTE_NORMAL);
Set createOptions = new HashSet();
createOptions.add(SMB2CreateOptions.FILE_RANDOM_ACCESS);
File f = share.openFile(folderName+"\\"+fileName, new HashSet(Arrays.asList(new AccessMask[]{AccessMask.GENERIC_ALL})), fileAttributes, SMB2ShareAccess.ALL, SMB2CreateDisposition.FILE_OVERWRITE, createOptions);

OutputStream oStream = f.getOutputStream();
oStream.write(fileContents.getBytes());
oStream.flush();
oStream.close();
}
} catch (IOException e) {
e.printStackTrace();
}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post