SMBLibrary.Client.Extension.FluentConnect
0.5.4
dotnet add package SMBLibrary.Client.Extension.FluentConnect --version 0.5.4
NuGet\Install-Package SMBLibrary.Client.Extension.FluentConnect -Version 0.5.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SMBLibrary.Client.Extension.FluentConnect" Version="0.5.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SMBLibrary.Client.Extension.FluentConnect --version 0.5.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SMBLibrary.Client.Extension.FluentConnect, 0.5.4"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SMBLibrary.Client.Extension.FluentConnect as a Cake Addin #addin nuget:?package=SMBLibrary.Client.Extension.FluentConnect&version=0.5.4 // Install SMBLibrary.Client.Extension.FluentConnect as a Cake Tool #tool nuget:?package=SMBLibrary.Client.Extension.FluentConnect&version=0.5.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
About SMBLibrary.Client.Extension.FluentConnect:
SMBLibrary.Client.Extension.FluentConnect is a .NET library for access SMB resource easier with the underlying SMBLibrary
Using SMBLibrary.Client.Extension.FluentConnect:
- SMBPath object containing Host, Share, and Path properties. You can parse the path string using SMBPath.ParseFrom to obtain an SMBPath object.
public async Task SMBPath_ParseFrom()
{
var (isParsed, samplePath, parsedError) = SMBPath.ParseFrom(@"\\127.0.0.1\share\hello\sample.txt");
if (isParsed)
{
await Assert.That(samplePath.HostName).IsEqualTo("127.0.0.1");
await Assert.That(samplePath.ShareName).IsEqualTo("share");
await Assert.That(samplePath.Path).IsEqualTo(@"hello\sample.txt");
await Assert.That(samplePath.ToString()).IsEqualTo(@"\\127.0.0.1\share\hello\sample.txt");
}
else Assert.Fail(parsedError.Message);
}
- SMBClientFactory is responsible for attempting to connect to unknown SMB resources (You can specify the list of clients implemented by SMBLibrary.) and return the connection information containing Client, Dialect, and TransportType.
public void SMBClientFactory_TryConnect()
{
var (isSuccess, connectionInfo, error) = SMBClientFactory.TryConnectWithServerName("localhost");
//var (isSuccess, connectionInfo, error) = SMBClientFactory.TryConnectWithAddress(IPAddress.Parse("127.0.0.1"));
if (isSuccess)
{
var client = connectionInfo.SMBClient;
var dialect = connectionInfo.Dialect;
var transportType = connectionInfo.TransportType;
}
else Assert.Fail(error.Message);
}
- You can manage different SMB path login credentials by implementing ISMBCredentialGetter
public class SMBCredientailGetter : ISmbCredientailGetter
{
public ISMBCredientail GetFrom(SMBPath path)
{
if (path is not null)
{
switch (path.HostName)
{
case "localhost":
return SMBCredientail.From(userName: "userName", password: "...");
default:
return SMBCredientail.NoCredientail;
}
}
else return SMBCredientail.NoCredientail;
}
}
- You can manage the client state using SMBTransaction. When dispose occurs, it will automatically execute disconnect and logout (if login credential was provided when creating the Transaction).
public void SMBTransaction_StartTransaction()
{
var (isPathParsed, sampleFolderPath, _) = SMBPath.ParseFrom(@"\\localhost\d$");
if (isPathParsed)
{
/* We can start transaction without login credientail
* using (var transaction = SMBTransaction.NewTransaction<SMBSimpleTransaction>(sampleSmbPath, afterConnectInitial: _tran => _tran.InitialHandles()))
* using (var transaction = SMBTransaction.NewTransaction<SMBSimpleTransaction>(sampleSmbPath, afterConnectInitial: _tran => _tran.InitialHandles(), SMBCredientail.NoCredientail))
*
* Or with login credientail
* using (var transaction = SMBTransaction.NewTransaction<SMBSimpleTransaction>(sampleSmbPath, afterConnectInitial: _tran => _tran.InitialHandles(), username: , password: ))
* using (var transaction = SMBTransaction.NewTransaction<SMBSimpleTransaction>(sampleSmbPath, afterConnectInitial: _tran => _tran.InitialHandles(), SMBCredientail.From(userName: , password: ) ))
*
* Or with credientail managed by ISmbCredientailGetter implement
*/
var credientailGetter = new SMBCredientailGetter();
using (var transaction = credientailGetter.NewTransaction<SMBSimpleTransaction>(sampleFolderPath, afterConnectInitial: _tran => _tran.InitialHandles()))
{
var fileInfosInFolder = transaction.FolderHandle.GetFiles(sampleFolderPath, searchOption: SearchOption.TopDirectoryOnly).ToArray();
(isPathParsed, var samplePath, _) = sampleFolderPath.GetRelative("text.txt");
if (isPathParsed) transaction.FileHandle.CreateFile(samplePath, "test");
}
}
}
- SMBTransaction can be implemented to include different processing components. For example, SMBSimpleTransaction is defined as follows, including implementations of SMBDirectory and SMBFile (each containing some basic functionalities).
- Additionally, the afterConnectInitial argument of SMBTransaction.NewTransaction provides an opportunity to pass parameters and perform flexible initialization settings.
public class SMBSimpleTransaction : SMBTransaction
{
public SMBFile FileHandle { get; private set; }
public SMBDirectory FolderHandle { get; private set; }
public void InitialHandles()
{
this.FileHandle = new SMBFile(this.Client);
this.FolderHandle = new SMBDirectory(this.Client);
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- SMBLibrary (>= 1.5.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.5.4 | 147 | 3/11/2025 |