Open Yaqr-rong opened 3 years ago
I check whether it exists in the shared folder,the folder is created if it does not exist,but run fail。
This is an error message:com.hierynomus.mssmb2.SMBApiException: STATUS_OBJECT_PATH_NOT_FOUND (0xc000003a)
This is an explanation of the documentation:{Path Not Found} The path %hs does not exist.
But it is useless for solving the problem。
This is my code: `
SMBClient client = new SMBClient();
try (Connection connection = client.connect("ip")) { AuthenticationContext ac = new AuthenticationContext("username", "password".toCharArray(), ""); Session session = connection.authenticate(ac);
try (DiskShare share = (DiskShare) session.connectShare(SHARE_FOLDER_PATH_HEADER)) { if(!share.folderExists(FOLDER_PATH)){ share.mkdir(FOLDER_PATH); //This is where things go wrong } InputStream in = null; OutputStream out = null; File localFile = new File(LOCAL_DIR); in = new BufferedInputStream(new FileInputStream(localFile)); com.hierynomus.smbj.share.File smbFileRead = share.openFile(SHARE_FOLDER_PATH+ File.separator + FILE_NAME, EnumSet.of(AccessMask.GENERIC_ALL), null, SMB2ShareAccess.ALL, SMB2CreateDisposition.FILE_OVERWRITE_IF, null); OutputStream outputStream = smbFileRead.getOutputStream(); out = new BufferedOutputStream(outputStream); FileCopyUtils.copy(in, out);`
I'm not sure what the problem is? A mkdir will only create 1 level of directories, so it does not do a recursive create. If you want this, you can use the helper method SmbFiiles.mkdirs
mkdir
SmbFiiles.mkdirs
I check whether it exists in the shared folder,the folder is created if it does not exist,but run fail。
This is an error message:com.hierynomus.mssmb2.SMBApiException: STATUS_OBJECT_PATH_NOT_FOUND (0xc000003a)
This is an explanation of the documentation:{Path Not Found} The path %hs does not exist.
But it is useless for solving the problem。
This is my code: `
SMBClient client = new SMBClient();
try (Connection connection = client.connect("ip")) { AuthenticationContext ac = new AuthenticationContext("username", "password".toCharArray(), ""); Session session = connection.authenticate(ac);