PC Review


Reply
Thread Tools Rate Thread

how to compare a Long with a UInt64 (or convert fromLong to UInt64)?

 
 
Wolfgang Kaml
Guest
Posts: n/a
 
      20th Dec 2003
Dear all,

I am using the following code to retrieve the size of a certain file and the
available (free) space on the disk. The problem is, that I get the size of
the file returned as a Long and the size of free disk space as UInt64.
Apparently, there are no function to convert a Long to a UInt64 or to
compare the two (I'm not expecting to convert the UInt64 to a Long
necessarily, but it should work the other way round, right?).

Short story: How to compare a Long with a UInt64?

Long story, please read the code below to see the problem described in the
very last comment statement
'------ snip - snip -------
Dim objDiskClass As System.Management.ManagementClass
Dim objDisks As System.Management.ManagementObjectCollection
Dim objDisk As System.Management.ManagementObject
Dim lFileSize As Long
Dim uiDiskSpace As System.UInt64

Dim objFileInfo = New FileInfo("MyFile.txt")
lFileSize = objFileInfo.Length

objDiskClass = New System.Management.ManagementClass("Win32_LogicalDisk")
objDisks = objDiskClass.GetInstances()

For Each objDisk In objDisks
If CStr(objDisk("Name")) = "D:" Then
uiDiskSpace = CType(objDisk("FreeSpace"), System.UInt64)
Exit For
End If
Next objDisk

'now I got the File Size as Long in lFileSize
'and the Free Disk Space as UInt64 in uiDiskSpace
'??? How can I compare the two ???
'------ snip - snip -------


Thank you for all of your help and have some great holidays too!
Wolfgang


 
Reply With Quote
 
 
 
 
Guest
Posts: n/a
 
      22nd Dec 2003
Trying something like Convert.ToUInt64(mylong.ToString())
or vice-versa.

-----Original Message-----
>Dear all,
>
>I am using the following code to retrieve the size of a

certain file and the
>available (free) space on the disk. The problem is, that

I get the size of
>the file returned as a Long and the size of free disk

space as UInt64.
>Apparently, there are no function to convert a Long to a

UInt64 or to
>compare the two (I'm not expecting to convert the UInt64

to a Long
>necessarily, but it should work the other way round,

right?).
>
>Short story: How to compare a Long with a UInt64?
>
>Long story, please read the code below to see the problem

described in the
>very last comment statement
>'------ snip - snip -------
>Dim objDiskClass As System.Management.ManagementClass
>Dim objDisks As

System.Management.ManagementObjectCollection
>Dim objDisk As System.Management.ManagementObject
>Dim lFileSize As Long
>Dim uiDiskSpace As System.UInt64
>
>Dim objFileInfo = New FileInfo("MyFile.txt")
>lFileSize = objFileInfo.Length
>
>objDiskClass = New System.Management.ManagementClass

("Win32_LogicalDisk")
>objDisks = objDiskClass.GetInstances()
>
>For Each objDisk In objDisks
> If CStr(objDisk("Name")) = "D:" Then
> uiDiskSpace = CType(objDisk("FreeSpace"),

System.UInt64)
> Exit For
> End If
>Next objDisk
>
>'now I got the File Size as Long in lFileSize
>'and the Free Disk Space as UInt64 in uiDiskSpace
>'??? How can I compare the two ???
>'------ snip - snip -------
>
>
>Thank you for all of your help and have some great

holidays too!
>Wolfgang
>
>
>.
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ulong vs UInt64 Sanjib Biswas Microsoft C# .NET 9 5th Jul 2006 03:14 AM
uint64 Bob Allen Microsoft C# .NET 10 30th Apr 2006 05:21 PM
Is it possible to divide a UInt64 by another UInt64? ThunderMusic Microsoft Dot NET 5 23rd Mar 2005 04:03 AM
how to compare a Long with a UInt64 (or convert fromLong to UInt64)? Wolfgang Kaml Microsoft VB .NET 12 22nd Dec 2003 03:01 AM
Convert System::UInt64 to unsigned long Mike Miller Microsoft VC .NET 3 17th Nov 2003 07:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:37 PM.