0

I tried two different codes to get the C Drive Disk Space on my VPS, they are as follows:

System.IO.DriveInfo di = new System.IO.DriveInfo("C");
Console.WriteLine(di.TotalFreeSpace);

And other one is

using System;
using System.Management;

public string GetFreeSpace();
{ 
    ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"c:\"");
    disk.Get();
    string freespace = disk["FreeSpace"];
    return freespace;
}

Now these codes are working fine on localhost, however, whenever I am running them under ASP.Net (FW4) Application, W3WP.exe crashes and IIS technicaly restart automatically.

Is there a way around to get the disk space on my VPS without crashing the W3WP.exe ?

I am using IIS 7.5 with Windows Server 2008 R2 Standard from GoDaddy

Any help appreciated :)

GKG4
  • 440
  • 1
  • 4
  • 16

1 Answers1

0

I think you have to run the AppPool under a different user not the default AppPoolIdentity user becouse maybe it doesn't have enough privilage to access this information.

Peter Kiss
  • 9,309
  • 2
  • 23
  • 38
  • Well, its currently running under plesk(default)(4.0)pool with Identity as IWAM_Plesk(default). I tried changing it to all given pools, but except above, every other pool is giving 500 Internal Server Error – GKG4 Aug 10 '14 at 13:25