I was taken by surprise when one of my servers hung up. No web site was showing I was getting an error of service not available message in my explorer. I remotely logged into my server and found out that one of the drives had run out of space; and the disk cleaning utility had fired up and was running consuming all the resources of my server. That was bad news for me.
So I decided to create a utility for alerting myself before time and here is a piece of code that I would like to share.
I am using the new class of DriveInfo available in .Net 2.0 in the System.IO namespace.
I simply send an email alert at my address informing me that its time for re-actions
.
Dim CDriveFreeSpace As Long = 2147483648 2GB
Dim DDriveFreeSpace As Long = 1073741824 1GB
For Each curDrive As DriveInfo In My.Computer.FileSystem.Drives
If curDrive.DriveType = DriveType.Fixed Then
Dim theFreeSpace As Long = curDrive.AvailableFreeSpace
If curDrive.Name = “C:\” And theFreeSpace <= CDriveFreeSpace Then
‘ send mail
End If
If curDrive.Name = “D:\” And theFreeSpace <= DDriveFreeSpace Then
’ send mail
End If
End If
Next
You can use the code as you like create a VB application, schedule it or else and please do share with me in what different ways can one use this code to solve the problem that I have just encountered.




What if the drive info you’re looking for isn’t on you machine but a server on your network?
How do I initialize the Driveinfo variable to a different machine?
Thanks,
Steve
gr8 stuff
http://soft-engineering.blogspot.com