Class WindowsNetworkFileShare
For interacting with SMB network file shares on Windows
public class WindowsNetworkFileShare : IDisposable
- Inheritance
-
WindowsNetworkFileShare
- Implements
- Inherited Members
Constructors
WindowsNetworkFileShare(string, NetworkCredential, IMPR)
Initializes a new instance of the WindowsNetworkFileShare class.
public WindowsNetworkFileShare(string networkName, NetworkCredential credentials, IMPR mpr = null)
Parameters
networkNamestringAddress of the file share
credentialsNetworkCredentialUsername and password for accessing the file share
mprIMPRA class that handles calls to mpr.dll or performs same operations
Methods
Dispose()
public void Dispose()
Dispose(bool)
Disposes the object, cancels connection with file share
protected virtual void Dispose(bool disposing)
Parameters
disposingboolNot used
~WindowsNetworkFileShare()
Finalizes an instance of the WindowsNetworkFileShare class.
protected ~WindowsNetworkFileShare()
GetLastError(out int, out StringBuilder, int, out StringBuilder, int)
Retrieves the most recent extended error code set by a WNet function
Wraps an underlying P/Invoke call to mpr.dll - https://docs.microsoft.com/en-us/windows/desktop/api/winnetwk/nf-winnetwk-wnetgetlasterrorapublic int GetLastError(out int error, out StringBuilder errorBuf, int errorBufSize, out StringBuilder nameBuf, int nameBufSize)
Parameters
errorintThe error code reported by the network provider.
errorBufStringBuilderString variable to receive the description of the error
errorBufSizeintSize of error buffer
nameBufStringBuilderString variable to receive the network provider raising the error
nameBufSizeintSize of name buffer
Returns
- int
If the function succeeds, and it obtains the last error that the network provider reported, the return value is NO_ERROR.
If the caller supplies an invalid buffer, the return value is ERROR_INVALID_ADDRESS.
WNetGetLastError(out int, out StringBuilder, int, out StringBuilder, int)
Retrieves the most recent extended error code set by a WNet function
P/Invoke call to mpr.dll - https://docs.microsoft.com/en-us/windows/desktop/api/winnetwk/nf-winnetwk-wnetgetlasterrora[Obsolete("Use GetLastError instead. This direct call to mpr.dll will be removed in a future release")]
public static extern int WNetGetLastError(out int error, out StringBuilder errorBuf, int errorBufSize, out StringBuilder nameBuf, int nameBufSize)
Parameters
errorintThe error code reported by the network provider.
errorBufStringBuilderString variable to receive the description of the error
errorBufSizeintSize of error buffer
nameBufStringBuilderString variable to receive the network provider raising the error
nameBufSizeintSize of name buffer
Returns
- int
If the function succeeds, and it obtains the last error that the network provider reported, the return value is NO_ERROR.
If the caller supplies an invalid buffer, the return value is ERROR_INVALID_ADDRESS.