The NetFile object in QIE provides a reliable way to interact with files located on remote SMB network shares using explicit credentials, instead of relying on the local system account that the QIE service runs under.
This is particularly useful in environments where:
- The QIE service account does not have access to the network share
- Access requires domain credentials
- You need fine control over SMB behavior and connection settings
Why use NetFile instead of local file operations?
Standard file operations in QIE (e.g., readFile, writeFile) run under the QIE service account. This can cause issues when accessing remote shares that require authentication.
NetFile solves this by:
- Allowing explicit credentials (domain + username + password)
- Supporting direct SMB access to remote shares
- Providing a consistent API similar to java.io.File, but for network locations
Key Benefits of NetFile
1. Access remote shares with credentials
NetFile connects to SMB shares using provided credentials instead of the QIE service account.
- Supports domain;username format
- Works even when the service account has no access
2. Full file manipulation support
NetFile can be used with standard QIE file operations such as:
- readFile
- writeFile
- deleteFile
- moveFile
Internally, it wraps SMB operations and exposes them in a familiar way.
3. Behavior consistent with local files
NetFile mimics the behavior of java.io.File:
- Methods like exists(), delete(), mkdirs() return boolean results
- Directory listing returns NetFile objects, not SMB-specific types
This makes it easier to write scripts without worrying about SMB-specific APIs.
4. Automatic SMB path handling
NetFile automatically:
- Converts Windows-style paths (\\server\share) to SMB format
- Ensures paths are prefixed with smb:// when needed
5. Connection lifecycle management (autoClose)
NetFile includes built-in connection management:
- By default, connections are automatically closed after a period of inactivity
- You can disable this with autoClose=false and manually call close()
This helps prevent:
- Resource leaks
- Stale SMB connections
6. Safe file access and locking
NetFile uses SMB share modes to:
- Prevent reading files that are still being written
- Detect if a file is in use by another process
This reduces the risk of:
- Partial reads
- Data corruption during file transfers
7. Configurable SMB behavior
Optional parameters allow customization of the SMB connection, such as:
- File and directory modes
- Timeout settings
- Other jcifs-ng configuration options
Format:
key=value
key2=value2
For additional examples on usage of these optional parameters see what-are-the-network-share-configuration-parameters
When should I use NetFile?
Use NetFile when:
- Accessing remote SMB shares
- You need to provide credentials explicitly
- The QIE service account cannot access the share
- You need reliable file locking or concurrency handling
Do not use NetFile for:
- Local file system access (use standard file APIs instead)
- Simple file operations where the service account already has access
Additional Related Links:
what-are-the-network-share-configuration-parameters
filenotfoundexception-when-using-netfile-fileoutputstream
how-to-connect-to-remote-share-mapping-node-with-credentials
how-disable-dfs-network-shares-netfile-domain-environments
java.io.File