473,320 Members | 1,951 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,320 software developers and data experts.

Help: checking available disk space

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
Jul 22 '05 #1
3 1814
>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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 22 '05 #2
Hi matias,

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

thanks

"Mattias Sjögren" wrote:
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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Jul 22 '05 #3
Hi,

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

serge

"Mattias Sjögren" wrote:
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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Jul 22 '05 #4

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

Similar topics

2
by: Paris_Sucks | last post by:
I'm trying to redirect when testing for certain condidtions as shown below. When the conditions are ture, it redirects, but still goes ahead and processes the sql query. What am I doing wrong??? ...
1
by: Beyonder | last post by:
I'm using InnoDB with Mysql and I've used delete to delete over 10 million records, but the InnoDB database is still the same size on the disk (over 100 gigs) is there a way to get Mysql/InnoDB to...
4
by: Morgan Leppink | last post by:
Hey all - We are running SQL 2000 with ALL available service packs, etc. applied. We just built a brand new database server, which has dual 2Ghz XEONs, 2GB memory, and the following disk...
67
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. ...
3
by: Lamont | last post by:
VB.NET Can anyone tell me how I can get the Drive Space information from a remote computer on the same domain and physical network? Primarily I need the Total disk space and space used or free...
3
by: serge calderara | last post by:
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...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
10
by: eastcoastguyz | last post by:
(I've not done C prorgamming in such a long time, I have forgotten how to do this.) I'm writing a program, where it fopens a file with "a+", and I want to be able to continue writing to this...
0
by: elias.farah | last post by:
Hello Everyone, I've been searching for a few hours on how to check the available disk space (on a Flash disk actually) from within MS-Access. Basically, I want to ensure there is adequate...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.