List files on Windows shared folder


If we spot task to download or list files from shared folder on Windows machine, there are some options we have to solve it:

  1. You can mount this shared folder to Linux server with WF installation, but it required some admin activities.
  2. You can read files and upload them to S3 using RPA, here you can find more details.
  3. You can use library, which is bundled into WF installation.

Below you can find code example for readilng list of files in shared Windows folder:

import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbException;
import jcifs.smb.SmbFile;
import jcifs.smb.SmbFileOutputStream;
// we need domain, folder path, user and password 
auth = new NtlmPasswordAuthentication(domain, user, password);
file = new SmbFile(path, auth);
files = file.listFiles();

For more details of jcifs API reffer to: