我觉得自己这样做有很多只是为了确保文件名不使用。有没有更好的办法?
Directory.Exists(名)|| File.Exists(名)
解决方案
肯定的:)
内部静态布尔FileOrDirectoryExists(字符串名称)
{
返程(Directory.Exists(名称)|| File.Exists(名称));
}
I find myself doing this a lot just to ensure the filename is not in use. Is there a better way?
Directory.Exists(name) || File.Exists(name)
解决方案
Sure :)
internal static bool FileOrDirectoryExists(string name)
{
return (Directory.Exists(name) || File.Exists(name));
}