FreeSpace Property in C++ .Net

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.
 
B

Bonj

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"]);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top