Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.
C#
{
    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);
}
Posted
Updated 4-Jul-14 0:22am
v2

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[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900