Help: checking available disk space

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

Guest

Dear all,

I need to check the availbale disk space.
For that I have used following code :

m_diskMngt = New ManagementObject("win32_logicaldisk.deviceid=""E:""")

This works fine but as my drive letter can be something else, I try to use
the following :

m_LogDrive = Left(Path.GetPathRoot(sPath), 2)
mngObj = "'win32_logicaldisk.deviceid=" & Chr(34) & Chr(34) & m_LogDrive &
Chr(34) & Chr(34)
m_diskMngt = New ManagementObject(mngObj)

Using this get error message "Invalid parameter"
When I check the result string it is similar to the first one

Any idea what is wrong? or is there a simple way doing this?

thnaks for your help
regards
serge
 
mngObj = "'win32_logicaldisk.deviceid=" & Chr(34) & Chr(34) & m_LogDrive &
Chr(34) & Chr(34)
m_diskMngt = New ManagementObject(mngObj)

You probably shouldn't have double Chr(34) there. Keep in mind that
that is just VB syntax for having a single double-quote in a string.
Try

mngObj = "'win32_logicaldisk.deviceid=""" & m_LogDrive & """"



Mattias
 
Hi matias,

I have tryied what you was sugesting, but it fails similar.
I could not rebuild that exact string sounds so crazy

thanks
 
Hi,

Sorry I forget that I post it already once
Proble is solved from your solution in second post
thanks

serge
 
Back
Top