终极 .NET 文件和目录实用程序库?

发布于 2024-08-28 13:18:30 字数 772 浏览 2 评论 0原文

我发现自己一直在编写文件和目录实用函数,我想知道是否有好的文件和目录库已经实现了比 System.IO 中默认提供的更广泛的集。我正在寻找的功能类型是这样的:

public static void GetTemporaryDirectory() 
{ 
   string tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); 
   Directory.CreateDirectory(tempDirectory); 
   return tempDirectory; 
}

public static void CreateEmptyFile(string filename) 
{ 
    File.Create(filename).Dispose(); 
} 

public static void CreateEmptyFile(string path, string filename) 
{ 
    File.Create(Path.Combine(path, filename)).Dispose(); 
} 

public static void CreateDirectory(string path)
{
    Directory.CreateDirectory(path);
}

public static void CreateDirectory(string path, string childpath)
{
    Directory.CreateDirectory(Path.Combine(path, childpath));
}

I find myself writing file and directory utility functions all the time, and I was wondering if there is good file and directory library that already implements a more extensive set than available by default in System.IO. The kind of functions I'm looking for is things like:

public static void GetTemporaryDirectory() 
{ 
   string tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); 
   Directory.CreateDirectory(tempDirectory); 
   return tempDirectory; 
}

public static void CreateEmptyFile(string filename) 
{ 
    File.Create(filename).Dispose(); 
} 

public static void CreateEmptyFile(string path, string filename) 
{ 
    File.Create(Path.Combine(path, filename)).Dispose(); 
} 

public static void CreateDirectory(string path)
{
    Directory.CreateDirectory(path);
}

public static void CreateDirectory(string path, string childpath)
{
    Directory.CreateDirectory(Path.Combine(path, childpath));
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

毁虫ゝ 2024-09-04 13:18:30

尽管我完全同意上面的评论,但也许这些库可能会引起兴趣:

使用 FileDirectoryPath 更新了帖子链接,看起来与 OP 请求完全匹配。

Although I agree completely with the comments made above, perhaps these libraries might be of interest:

Updated post with FileDirectoryPath link, which looks to be an exact match for OPs request.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文