我正在使用SMBClient
Java 连接到我的 SMB 服务器。
如何递归扫描我的整个 SMB 共享以获取所有扩展名为 .mp4 的文件的列表?
这是我只扫描一个指定目录的代码:
private void btnFileCountActionPerformed(java.awt.event.ActionEvent evt) {
SMBClient client = new SMBClient();
try (Connection connection = client.connect("192.168.X.XXX")) {
AuthenticationContext ac = new AuthenticationContext("XXXXXXX@hotmail.com", "XXXXXX".toCharArray(), "Mastafin");
Session session = connection.authenticate(ac);
try (DiskShare share = (DiskShare) session.connectShare("Folder With Spaces")) {
for (FileIdBothDirectoryInformation f : share.list("LOTS OF SUBDIRS TO SCAN", "*.mp4")) {
System.out.println("File : " + f.getFileName());
}
} catch (Exception e) {
System.out.println(e);
}
} catch (Exception e) {
System.out.println(e);
}
}