请问如何获取给定目录所在磁盘的容量?(C#)
现需要将产生报表保存在某个目录(可能是本地,也可能是网络映射磁盘),在保存之前需要判断这个目录是否存在,目录是否可写,目录所在磁盘空间大小, 假设这些报表文件不超过5MB,
string directoryPos= ""; //Given directory
DirectoryInfo dir = new DirectoryInfo(directoryPos);
bool isValid = true;
if(!dir.Exists) //Judge the directory whether exist
{
isValid = false;
}
else if (FileAttributes.ReadOnly.CompareTo(dir.Attributes
& FileAttributes.ReadOnly) == 0) //Judge whether the directory is readonly
{
isValid = false;
}
else if () //怎样得到该目录所在磁盘容量
{
isValid = false;
}
不知道大家有没有碰到过类似的问题?