DiLu.Expansion.File 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package DiLu.Expansion.File --version 1.0.2
                    
NuGet\Install-Package DiLu.Expansion.File -Version 1.0.2
                    
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.2" />
                    
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.2" />
                    
Directory.Packages.props
<PackageReference Include="DiLu.Expansion.File" />
                    
Project 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.2
                    
#r "nuget: DiLu.Expansion.File, 1.0.2"
                    
#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.2
                    
#: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.2
                    
Install as a Cake Addin
#tool nuget:?package=DiLu.Expansion.File&version=1.0.2
                    
Install as a Cake Tool

的卢文件扩展组件

介绍

这是一个文件扩展组件,提供了一些常用的文件操作方法

使用说明

支持的文件系统类型

/// <summary>
///     文件系统类型
/// </summary>
public enum FileSystemType
{
    /// <summary>
    ///     本地磁盘
    /// </summary>
    LocalDisk = 0,

    /// <summary>
    ///     FTP服务器
    /// </summary>
    Ftp = 1
}

LocalDisk(本地磁盘)

//获取文件流
var fileStreamResult = "FilePath".GetLocalDiskFile();

//保存文件后获取保存的相对路径
var saveFileResult = await "FilePath".SaveLocalDiskFileToLocalDiskAsync(TargetFolder);
var saveFileResult = await fileStream.SaveFileStreamToLocalDiskAsync(TargetFolder, fileExtension);

//删除文件
"filePath1".DeleteLocalDiskFile();
//删除文件夹
"filePath1".DeleteLocalDiskFolder();

//查询文件列表
await foreach (var file in "folderPath".SearchLocalDiskFileAsync())
{
    Console.WriteLine(JsonConvert.SerializeObject(file));
    await Task.Delay(0);
}

FTP(FTP服务器)

//获取文件流
var fileResult = await "2025/04/07/2025040716373076913.jpg"
            .GetFtpFileAsync(new DiLuFtpConfig(FtpAddress, FtpUser, FtpPassword, TargetFolder), true);

//保存文件后获取保存的相对路径
var saveFileResult = await Path.Combine(SourceRootFolder, SourceFileRelativePath1)
            .SaveLocalDiskFileToFtpAsync(new DiLuFtpConfig(FtpAddress, FtpUser, FtpPassword, TargetFolder));
var saveFileResult = await fileStream.SaveFileStreamToFtpAsync();

//删除文件
await "2025/04/07/2025040716360333473.jpg"
            .DeleteFtpFileAsync(new DiLuFtpConfig(FtpAddress, FtpUser, FtpPassword, TargetFolder));
//删除文件夹
await new DiLuFtpConfig(FtpAddress, FtpUser, FtpPassword, TargetFolder)
            .DeleteFtpFolderAsync(false);

//查询文件列表
await foreach (var file in new DiLuFtpConfig(FtpAddress, FtpUser, FtpPassword, "/")
                   .SearchFtpFileAsync(searchPattern: @"^([\s\S]*)211([\s\S]*)(\.\w+)$"))
{
    Console.WriteLine($"{file.FileName}-----{file.Extension}---{file.DirectoryName}");
    await Task.Delay(0);
}
Product 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.

Version Downloads Last Updated
1.1.0 217 4/21/2025
1.0.4 152 4/12/2025
1.0.3 208 4/10/2025
1.0.2 200 4/8/2025
1.0.1 384 3/24/2025