VPKSoft.UNCUtil
An (library) utility to access Windows (SMB/CIFS) shares with credentials.
Features
- Current version 1.0.0.0 (20.10.2018)
- A helper/wrapper class library to access SMB/CIFS file shares with credentials in a very simple manner.
- Based on the Windows API‘s functions WNetAddConnection2 and WNetCancelConnection2, so P/Invoke, sorry about that :sweat:
- Very simple to use.
Requirements
- A Microsoft® Windows® supporting .NET Framework v.4.5
- LGPL v3 compatible application
Changes
- –
Usage
private void Test()
{
try // an error might occur..
{
// IDisposable so using..
using (UNCLogin share1 = new UNCLogin(@"\\server1\share1",
new System.Net.NetworkCredential("username1", "password1", "domain1")))
{
// IDisposable so using..
using (UNCLogin share2 =
new UNCLogin(@"\\server2\share2", new System.Net.NetworkCredential("username2", "password2", "domain2")))
{
// a normal file operation with the given credentials.
File.Copy(@"\\server1\share1\somefile.dat", @"\\server2\share2\somefile.dat");
}
}
}
catch (Exception ex)
{
// show the error message..
MessageBox.Show(ex.Message);
}
}