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

Disk FreeSpace problem.

Dan
I've written a short function to return the amount of free
disk space on a specified drive (for example c:) and it
works fine on my development platform. In production,
however, I am getting an exception that I can't figure
out. Any help would be appreciated.

Here's my code:

Public Function GetFreeSpace(ByVal strDiskDrive As String)
As Int64
Try
Dim disk As New ManagementObject
("win32_logicaldisk.deviceid=""" + strDiskDrive + """")
Return CLng(disk("FreeSpace").ToString)
Catch ex As Exception
Throw New Exception("Error In
GeneralRoutines.IO.GetFreeSpace: " + ex.ToString)
End Try
End Function

Here's the exception I'm getting on my production system:

Error In GeneralRoutines.IO.GetFreeSpace:
System.TypeInitializationException: The type initializer
for "System.Management.MTAHelper" threw an exception. --->
System.Runtime.InteropServices.COMException (0x80131701):
Unknown Error
at System.Management.MTAHelper..cctor()
--- End of inner exception stack trace ---
at System.Management.MTAHelper.CreateInMTA(Type type)
at System.Management.ManagementPath.CreateWbemPath
(String path)
at System.Management.ManagementPath..ctor(String path)
at System.Management.ManagementObject..ctor(String path)
at EnrollLink.GeneralRoutines.IO.GetFreeSpace(String
strDiskDrive)
at EnrollLink.GeneralRoutines.IO.GetFreeSpace(String
strDiskDrive)
at ELBatchService.Control.BatchControl(Boolean&
boolForceFilePurge, Boolean& boolForceRules)

-dan-
Nov 20 '05 #1
2 3310
* "Dan" <dk****************@yahoo.com> scripsit:
I've written a short function to return the amount of free
disk space on a specified drive (for example c:) and it
works fine on my development platform. In production,
however, I am getting an exception that I can't figure [...]
Error In GeneralRoutines.IO.GetFreeSpace:
System.TypeInitializationException: The type initializer
for "System.Management.MTAHelper" threw an exception. --->
System.Runtime.InteropServices.COMException (0x80131701):


Which Windows version do you use?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
dan
-----Original Message-----

Which Windows version do you use?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
.


Windows 2000 Server (SP4).

-dan-
Nov 20 '05 #3

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

Similar topics

2
by: | last post by:
Hi every one I try to get hard disk serial number how can i do this ? -> THANK'S A LOT
0
by: Larry Melia | last post by:
I've been working with Oracle 9i for about 8 months on windows XP (the same problem occurs with WIN2000). However, I noticed that the latest release has some software that "hits the disk" about...
2
by: Larry Melia | last post by:
I've been working with Oracle 9i for about 8 months on windows XP (the same problem occurs with WIN2000). However, I noticed that the latest release has some software that "hits the disk" about...
4
by: sandip | last post by:
Hi, Can anyone tell me how to calculate the ctual disk space needed for a table? The record length and number of records are known. A rough estimate of the disk space would suffice. Please...
12
by: New World Order Pigs | last post by:
Is there no way in .net to get disk space remaining for a given drive??? I can't believe it and yet is seems to be so. If someone knows of a way to do this in the .net libraries I'd be very much...
4
by: andrewcw | last post by:
If I have a drive letter I can get the the drive info from WMI like this string ltrDr=theSharePath.Substring(0,2); // must be in form of "E: string wackyQuery...
2
by: AlirezaH | last post by:
How to measure hard disk capacity?
0
by: Derrick | last post by:
Good Morning! Is there a simple way to get freespace on a network drive, without going thru the hoops of setting up WMI? Something in the basic System.IO package? I have a basic file uploads...
10
by: gary0gilbert | last post by:
An unusual spin to this recurring disk or network error in a Terminal Server environment. Access 2000, Terminal Server 2000, file server is windows 2000. All users have a separate copy of the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.