473,394 Members | 2,031 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,394 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 1816
>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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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.