终极 .NET 文件和目录实用程序库?
我发现自己一直在编写文件和目录实用函数,我想知道是否有好的文件和目录库已经实现了比 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尽管我完全同意上面的评论,但也许这些库可能会引起兴趣:
使用 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.