我发现自己经常这样做只是为了确保文件名未被使用。有没有更好的办法?
Directory.Exists(name) || File.Exists(name)
最佳答案
当然 :)
internal static bool FileOrDirectoryExists(string name)
{
return (Directory.Exists(name) || File.Exists(name));
}
关于c# - 检查文件/目录是否存在 : is there a better way?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2570930/