-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectPaths.cs
More file actions
35 lines (29 loc) · 1014 Bytes
/
ProjectPaths.cs
File metadata and controls
35 lines (29 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.IO;
using System.Reflection;
namespace CustomSound;
/// <summary>
/// 项目路径管理工具类,提供项目相关目录的访问方法
/// </summary>
static class ProjectPaths
{
// 私有缓存字段(readonly)
/// <summary>
/// 缓存当前DLL文件所在的目录路径
/// </summary>
private static readonly string _dllDirectory =
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty;
// 公开属性(只读访问)
/// <summary>
/// 获取当前DLL文件所在的目录路径
/// </summary>
/// <returns>DLL文件所在目录的完整路径</returns>
public static string DllDirectory => _dllDirectory;
/// <summary>
/// 获取音效资源目录路径
/// </summary>
/// <returns>音效资源目录的完整路径</returns>
public static string SoundsDirectory
=> string.IsNullOrEmpty(_dllDirectory)
? string.Empty
: Path.Combine(_dllDirectory, "sounds");
}