ozakboy.DirectoryTreeGenerator
1.0.0
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
.NET Framework 4.6.2
This package targets .NET Framework 4.6.2. The package is compatible with this framework or higher.
dotnet add package ozakboy.DirectoryTreeGenerator --version 1.0.0
NuGet\Install-Package ozakboy.DirectoryTreeGenerator -Version 1.0.0
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="ozakboy.DirectoryTreeGenerator" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ozakboy.DirectoryTreeGenerator --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ozakboy.DirectoryTreeGenerator, 1.0.0"
#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 ozakboy.DirectoryTreeGenerator as a Cake Addin #addin nuget:?package=ozakboy.DirectoryTreeGenerator&version=1.0.0 // Install ozakboy.DirectoryTreeGenerator as a Cake Tool #tool nuget:?package=ozakboy.DirectoryTreeGenerator&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DirectoryTreeGenerator
DirectoryTreeGenerator 是一個功能豐富的 .NET 函式庫,專門用於生成目錄結構的 Markdown 文檔。透過這個工具,您可以輕鬆地將專案或任意目錄的結構轉換成清晰易讀的樹狀圖文件,並支援自訂圖示、過濾規則和統計資訊。
核心功能
- 🎯 自動掃描並生成目錄結構的 Markdown 文件
- 📁 支援自訂目錄和檔案的圖示
- 🔍 彈性的忽略規則設定(支援檔案、目錄、副檔名和 glob 模式)
- 📊 詳細的統計資訊(總檔案數、大小、類型分布等)
- ⚡ 高效能的檔案系統處理
- 🛠️ 支援多個 .NET 平台(.NET Standard 2.0/2.1, .NET 6.0-8.0, .NET Framework 4.6.2)
快速開始
安裝套件
使用 NuGet Package Manager:
Install-Package ozakboy.DirectoryTreeGenerator
或使用 .NET CLI:
dotnet add package ozakboy.DirectoryTreeGenerator
基本使用
// 建立預設配置的生成器
var generator = new DirectoryTreeGenerator();
// 生成目錄樹
generator.GenerateTree(
"C:\\YourProject", // 要掃描的根目錄
"C:\\Output" // 輸出目錄
);
使用配置檔案
- 在專案根目錄建立
directorytree.json
:
{
"outputFileName": "DirectoryStructure.md",
"includeFileSize": true,
"includeLastModified": true,
"includeStatistics": true,
"sortDirectoriesFirst": true,
"ignorePatterns": [
"**/bin/**",
"**/obj/**",
"**/.vs/**"
],
"fileExtensionIcons": {
".cs": "📝",
".json": "📋",
".md": "📄"
}
}
- 使用配置檔案初始化生成器:
// 使用指定的配置檔案路徑
var generator = new DirectoryTreeGenerator("path/to/directorytree.json");
// 或自動搜尋配置檔案
var generator = new DirectoryTreeGenerator();
配置選項
GeneratorConfig 類別屬性
屬性 | 類型 | 預設值 | 說明 |
---|---|---|---|
OutputFileName | string | "DirectoryStructure.md" | 輸出檔案名稱 |
DirectoryPrefix | string | "📁" | 目錄前綴圖示 |
DefaultFilePrefix | string | "📄" | 預設檔案前綴圖示 |
IndentSpaces | int | 2 | 縮排空格數 |
IncludeHeader | bool | true | 是否包含標題 |
HeaderText | string | "# Project Directory Structure" | 標題文字 |
IncludeFileSize | bool | false | 是否顯示檔案大小 |
IncludeLastModified | bool | false | 是否顯示最後修改時間 |
IncludeStatistics | bool | false | 是否包含統計資訊 |
SortDirectoriesFirst | bool | true | 是否將目錄排在檔案前面 |
忽略規則設定
支援多種忽略規則類型:
{
"ignorePatterns": ["**/temp/**"],
"ignoreDirectories": ["node_modules", "bin"],
"ignoreFiles": ["thumbs.db"],
"ignoreExtensions": [".log", ".tmp"]
}
輸出範例
# Project Directory Structure
📁 src/
📝 Program.cs (2.5 KB) - 2024-03-15 14:30:00
📋 Config.json (1.2 KB) - 2024-03-15 14:25:00
📁 tests/
📝 UnitTests.cs (3.8 KB) - 2024-03-15 14:35:00
## 目錄統計資訊
- 總目錄數:2
- 總檔案數:3
- 總大小:7.5 KB
- 最後更新:2024-03-15 14:35:00
### 檔案類型統計
- .cs:2 個檔案
- .json:1 個檔案
進階功能
自訂檔案圖示
可以為不同的副檔名設定專屬圖示:
{
"fileExtensionIcons": {
".cs": "📝",
".json": "📋",
".md": "📄",
".txt": "📃",
".xml": "📰",
".png": "🖼️",
".jpg": "🖼️",
".pdf": "📚",
".zip": "📦",
".exe": "⚙️",
".dll": "🔧"
}
}
程式碼中配置
也可以透過程式碼動態設定配置:
var config = new GeneratorConfig
{
OutputFileName = "MyDirectoryTree.md",
IncludeFileSize = true,
IncludeLastModified = true,
IncludeStatistics = true,
SortDirectoriesFirst = true,
IgnorePatterns = new[] { "**/bin/**", "**/obj/**" }
};
var generator = new DirectoryTreeGenerator(config);
支援的平台
- .NET Standard 2.0
- .NET Standard 2.1
- .NET 6.0
- .NET 7.0
- .NET 8.0
- .NET Framework 4.6.2
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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 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. |
.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 is compatible. |
.NET Framework | net461 was computed. net462 is compatible. 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.
-
.NETFramework 4.6.2
- System.Text.Json (>= 8.0.5)
-
.NETStandard 2.0
- System.Text.Json (>= 8.0.5)
-
.NETStandard 2.1
- System.Text.Json (>= 8.0.5)
-
net6.0
- System.Text.Json (>= 8.0.5)
-
net7.0
- System.Text.Json (>= 8.0.5)
-
net8.0
- System.Text.Json (>= 8.0.5)
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.0.0 | 65 | 11/19/2024 |
1.0.0-beta.4 | 32 | 11/19/2024 |
1.0.0-beta.3 | 36 | 11/15/2024 |
1.0.0-beta.2 | 31 | 11/13/2024 |
1.0.0-beta.1 | 33 | 11/13/2024 |