Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8589371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:02:32+00:00 2026-06-11T23:02:32+00:00

Im having issues on the following code when converting to Int64 or any big

  • 0

Im having issues on the following code when converting to Int64 or any big number. Any help is appreciated.

public static void GetDiskspace(string MachineName, string DriveLetter) 
{ 
  ConnectionOptions options = new ConnectionOptions(); 
  ManagementScope scope = new ManagementScope("\\\\" + MachineName + "\\root\\cimv2",  
  options); 
  scope.Connect(); 
  SelectQuery query1 = new SelectQuery("Select * from Win32_LogicalDisk"); 

  ManagementObjectSearcher searcher1 = new ManagementObjectSearcher(scope, query1); 
  ManagementObjectCollection queryCollection1 = searcher1.Get(); 

  foreach (ManagementObject mo in queryCollection1) 
  { 
      // Display Logical Disks information 

      if (mo["Name"].Equals(DriveLetter.ToUpper()+":"))
          if (((Int64)mo["FreeSpace"]) < (1024 * 1024 * 100)) //100GB  <<----HERE IS WHERE I GET THE ERROR
          {
              Console.WriteLine(MachineName + " ALERT. LOW SPACE ON DRIVE " + mo["Name"]);
              Console.WriteLine();
              Console.WriteLine("              Disk Name : {0}", mo["Name"]);
              Console.WriteLine("              Disk Size : {0}", mo["Size"]);
              Console.WriteLine("              FreeSpace : {0}", mo["FreeSpace"]);
              Console.WriteLine("          Disk DeviceID : {0}", mo["DeviceID"]);
              Console.WriteLine("        Disk VolumeName : {0}", mo["VolumeName"]);
              Console.WriteLine("        Disk SystemName : {0}", mo["SystemName"]);
              Console.WriteLine("Disk VolumeSerialNumber : {0}", mo["VolumeSerialNumber"]);
              Console.WriteLine();
          }
  } 
  string line; 
  line = Console.ReadLine();  
} 

EDIT: changed “Size” to “FreeSpace”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:02:33+00:00Added an answer on June 11, 2026 at 11:02 pm

    It’s ulong boxed into object. So you can only unbox it to ulong (i.e. UInt64).

     if (((UInt64)mo["Size"]) < (1024 * 1024 * 100))
    

    enter image description here

    Have a look at Win32_LogicalDisk class

    class Win32_LogicalDisk : CIM_LogicalDisk
    {
        ...
        uint64   Size;
        ...
    };
    

    An extract from Win32_LogicalDisk class properties description:

    Size

    Data type: uint64 
    Access type: Read-only Size of the disk drive.
    This property is inherited from CIM_LogicalDisk.
    

    P.S.:

    1) Actually if you do need to have Int64, you can do the following cast:

    (Int64)(UInt64)mo["Size"]
    

    2) You could read this article by Eric Lippert, clarifying the essence of the exception in question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having issues with the following code which loads an SQLite database. -
I'm having some issues getting file uploads to work correctly and the following code
I'm having issues when trying to schedule a UILocalNotification using the following code: -
I'm having some issues using the following code on user input: htmlentities($string, ENT_COMPAT, 'UTF-8');
I have the following code which returns a JSON array. I'm having issues putting
I'm having an issues with bottle python where I have the following code import
I'm having issues with the following code, where I use a JComboBox to change
I'm having some issues getting the following code to compile: GLint iModelMatrix = glGetUniformLocation(m_shaderProgramID,
I'm having some issues here. I am using the following code to generate the
I am having issues with the following code in Scala import org.junit.Test import org.junit.Assert._

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.