FreeSpace Property in C++ .Net

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am trying to use the FreeSpace property in C++ .Net, but I having
problems. I looked around and most of the examples I found are in VB or C#.

I tried to convert a C# example to a C++.Net program, but C++>Net does not
like when I use the FreeSpace property. Here is a piece of my code:

UInt64 PlotFileDrive::getDiskSpace()
{
String * myPath = ("win32_logicaldisk.deviceid=\"C:\"");

ManagementObject * disk = new ManagementObject(myPath);
if (NULL == disk)
return 0;
else
return Convert::ToUInt64(disk["FreeSpace"]);
}

C++>Net complains about the disk["FreeSpace"], the error message I got says:

error C2107: illegal index, indirection not allowed


Does anyboy have any C++ .Net examples using the FreeSpace property. I
appreciate any help I can get.
 
Try
UInt64 PlotFileDrive::getDiskSpace()
{
String * myPath = ("win32_logicaldisk.deviceid=\"C:\"");

ManagementObject * disk = new ManagementObject(myPath);
if (NULL == disk)
return 0;
else
return Convert::ToUInt64(disk->Item["FreeSpace"]);
}
 
Back
Top