DiLu.Expansion.File
1.0.3
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package DiLu.Expansion.File --version 1.0.3
NuGet\Install-Package DiLu.Expansion.File -Version 1.0.3
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="DiLu.Expansion.File" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DiLu.Expansion.File" Version="1.0.3" />
<PackageReference Include="DiLu.Expansion.File" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DiLu.Expansion.File --version 1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DiLu.Expansion.File, 1.0.3"
#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.
#:package DiLu.Expansion.File@1.0.3
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DiLu.Expansion.File&version=1.0.3
#tool nuget:?package=DiLu.Expansion.File&version=1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
的卢文件扩展组件
介绍
这是一个文件扩展组件,提供了一些常用的文件操作方法
使用说明
本地磁盘 (LocalDisk)
//获取文件流
var fileStream = await SourceFile.BuildGetLocalDiskFileConfig(SourceRootFolder, null).GetAsync();
var fileStream = await Path.Combine(SourceRootFolder, "", SourceFile).BuildGetLocalDiskFileConfig().GetAsync();
//保存文件后获取保存的相对路径
var fileRelativePath = await fileStream
.BuildSaveFileStreamToLocalDiskConfig(TargetFolder, FileGroupName, Path.GetExtension(SourceFile))
.SaveAsync();
Console.WriteLine($"保存的相对路径是:{fileRelativePath}");
//删除文件
await fileRelativePath.BuildDeleteLocalDiskFileConfig(TargetFolder, FileGroupName).DeleteAsync();
await fileFullPath.BuildDeleteLocalDiskFileConfig().DeleteAsync();
//删除文件夹
await directoryFullPath.BuildDeleteLocalDiskFolderConfig().DeleteAsync();
await rootDirectory.BuildDeleteLocalDiskFolderConfig(FileGroupName, "2025/03/28").DeleteAsync();
//查询文件列表
await foreach (var fileInfo in rootDirectory.BuildSearchLocalDiskFileConfig(FileGroupName, null,
SearchOption.AllDirectories).SearchAsync())
{
Console.WriteLine($"{fileInfo.FileName}-----{fileInfo.Extension}---{fileInfo.DirectoryName}");
await Task.Delay(0);
}
await foreach (var fileInfo in fileFullPath.BuildSearchLocalDiskFileConfig().SearchAsync())
{
Console.WriteLine($"{fileInfo.FileName}-----{fileInfo.Extension}---{fileInfo.DirectoryName}");
await Task.Delay(0);
}
FTP服务器 (FTP)
//获取文件流
var ftpClient = new AsyncFtpClient(FtpHost, FtpUser, FtpPassword, FtpPort);
var fileStream2 = await "2025/04/09/2025040920151015849.jpg"
.BuildGetFtpFileConfig("/", "Test", ftpClient, false).GetAsync();
await using (fileStream2)
{
Console.WriteLine($"文件大小 {fileStream2?.Length ?? 0}");
}
await ftpClient.CloseFtpClientConnectAsync();
//保存文件后获取保存的相对路径
var ftpClient = new AsyncFtpClient(FtpHost, FtpUser, FtpPassword, FtpPort);
var fileStream = await SourceFile.BuildGetLocalDiskFileConfig(SourceRootFolder, null).GetAsync();
await using (fileStream)
{
await fileStream
.BuildSaveFileStreamToFtpConfig("/", "Images", Path.GetExtension(SourceFile), ftpClient, false)
.SaveAsync();
}
await ftpClient.CloseFtpClientConnectAsync();
//删除文件
var ftpClient = new AsyncFtpClient(FtpHost, FtpUser, FtpPassword, FtpPort);
await "2025/04/10/2025041021432585288.jpg"
.BuildDeleteFtpFileConfig("/", "Images", ftpClient, false)
.DeleteAsync();
await ftpClient.CloseFtpClientConnectAsync();
//删除文件夹
var ftpClient = new AsyncFtpClient(FtpHost, FtpUser, FtpPassword, FtpPort);
await "/Images/".BuildDeleteFtpFolderConfig(ftpClient, false).DeleteAsync();
await ftpClient.CloseFtpClientConnectAsync();
//查询文件列表
var ftpClient = new AsyncFtpClient(FtpHost, FtpUser, FtpPassword, FtpPort);
await foreach (var fileInfo in "/".BuildSearchFtpFileConfig(ftpClient, false).SearchAsync())
{
Console.WriteLine($"{fileInfo.FileName}-----{fileInfo.Extension}---{fileInfo.DirectoryFullPath}");
await Task.Delay(0);
}
await ftpClient.CloseFtpClientConnectAsync();
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.