473,396 Members | 1,992 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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_LogicalDi sk")
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
Jul 21 '05 #1
1 1289
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 theavailable (free) space on the disk. The problem is, that I get the size ofthe 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 tocompare the two (I'm not expecting to convert the UInt64 to a Longnecessarily, 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 thevery last comment statement
'------ snip - snip -------
Dim objDiskClass As System.Management.ManagementClass
Dim objDisks As System.Management.ManagementObjectCollectionDim 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
.

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: ThunderMusic | last post by:
Hi, I have a problem, I have to do this (MyUInt64 / MyOtherUInt64). the IDE tells me that the / operator has not been overloaded for UInt64. Is there a way I can do what I need to do? Thanks
2
by: donbro | last post by:
If my read of the extension source (Mac/Modules/file/_Filemodule.c) is correct, the parameter sizes specified for data and resource file sizes are UInt32 where they should be UInt64. In both OS9...
2
by: jiangyh | last post by:
hi there : I have a question about how to convert Type to DbType? thanks a lot. jiangyh
3
by: Mike Miller | last post by:
What is the best way to convert a managed unsigned int64 to an unsigned long? Basically I need to do the following: System::UInt64 managedInt = 10; unsigned long unmanagedInt; unmanagedInt =...
12
by: Wolfgang Kaml | last post by:
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...
9
by: Sanjib Biswas | last post by:
Could anyone point out to me the difference between ulong (C#) and UInt64/ULong (VB.Net)? I was under the impression that both are same. Below C# code works fine for a particular value of 'data'...
5
by: stuie_norris | last post by:
Hi Group I am trying to write a method to unpack a byte array into an Uint64. But the results are wrong. public static void UnpackUint64(ref UInt64 dst, byte Data, ref uint Index) { dst =...
2
by: Pedrop | last post by:
I have to check if a long value is between two other long values (range check). Since all values are generated by shifting and because in java long is always signed the use of simple operators >= <=...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.