如何获得c#中共享文件夹路径的可用空间? [英] How to get free space of shared folder path in c#?
本文介绍了如何获得c#中共享文件夹路径的可用空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在c#中获得共享文件夹路径的可用空间?
我可以通过以下代码获取文件夹大小。但我希望获得免费空间。
How do I get free space of shared folder path in c#?
I am able to get the folder size via below code. But I want to get the free space.
{
foreach (string file in Directory.GetFiles(SharedServerDBBackUpPath))
{
if (File.Exists(file))
{
FileInfo finfo = new FileInfo(file);
folderSize += finfo.Length;
}
}
}
catch (NotSupportedException e)
{
Console.WriteLine("Unable to calculate folder size: {0}", e.Message);
}
推荐答案
文件夹中没有可用空间的概念,只有驱动器本身
winapi函数GetDiskFreeSpaceEx可以为您做到这一点
这篇文章 [ ^ ]
There is no concept of free space in a folder, only on the drive itself
The winapi function GetDiskFreeSpaceEx can do that for you
Example on this post[^]
我没有测试过这个解决方案,但它可能适合你:
http://www.sergey.co.uk/ShowThread.aspx?ID=4563&AspxAutoDetectCookieSupport=1 [ ^ ]
或者这个:
HTTP: //social.msdn.microsoft.com/Forums/en-US/b7db7ec7-34a5-4ca6-89e7-947190c4e043/get-free-space-on-network-share?forum=csharpgeneral [ ^ ]
干杯!
I didn't tested this solution, but it may work for you:
http://www.sergey.co.uk/ShowThread.aspx?ID=4563&AspxAutoDetectCookieSupport=1[^]
or this:
http://social.msdn.microsoft.com/Forums/en-US/b7db7ec7-34a5-4ca6-89e7-947190c4e043/get-free-space-on-network-share?forum=csharpgeneral[^]
Cheers!
这篇关于如何获得c#中共享文件夹路径的可用空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文