daily pastebin goal
11%
SHARE
TWEET

Untitled

a guest Jan 20th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ConnectionOptions oConn = new ConnectionOptions();
  2.  
  3. oConn.Username = "username";
  4. oConn.Password = "password";
  5. oConn.Authority = "ntlmdomain:XXX";
  6.  
  7. ManagementScope scope = new ManagementScope("\\Remote_Computer\root\CIMV2", oConn);
  8.  
  9. scope.Connect();
  10.  
  11. ObjectQuery query = new ObjectQuery("SELECT DeviceID, VolumeName FROM Win32_LogicalDisk where DeviceID = 'D:'");
  12.  
  13. ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
  14.  
  15. ManagementObjectCollection queryCollection = searcher.Get();
  16.  
  17. foreach (ManagementObject m in queryCollection)
  18. {
  19.       //error happens here
  20.       fs = m["FreeSpace"].ToString();
  21.  
  22.       freeSpace = Convert.ToInt64(fs);
  23. }
  24.    
  25. "SELECT FreeSpace FROM Win32_LogicalDisk where DeviceID = 'D:'"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top