Question

I have developed a website using asp.net. Unfortunately the host of this web site is not unlimited and people upload many things in it every day. Is there any way to show the remain of free host space through the asp.net? I mean, admin can check the remain space of host online from his/her admin panel. Is it possible?

Was it helpful?

Solution

btw, you already know how much space you got. ok? so i suggest that you put your total space in your web.config and then get sum of sizes of files already on the disk and subtract them.

       long totoalSpace = long.MaxValue; // as example
        long size = 0;
        string folderPath = @"d:/hostingpace/yourwebsite/files"; //sample path

        foreach (var item in Directory.GetFiles(folderPath))
        {
            size += new FileInfo(item).Length;
        }

        long remainingSpace = totoalSpace - size;

note that since you dont have access to phisyical path you should Server.MapPath to get the folder path..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top