Total/Free Space in Drive
Hi all,
Am in need of reading total space/Available space in a server,
I am able to get the size, if the server is mapped as a drive,
Here is the code i tried
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim allDr As DriveInfo()
allDr = DriveInfo.GetDrives()
For Each drv As DriveInfo In allDr
If (drv.DriveType = DriveType.Network) Then
Dim item2 As ListViewItem = New ListViewItem(drv.Name)
Dim totsiz, freeSpace As Double
totsiz = drv.TotalSize
freeSpace = drv.AvailableFreeSpace
totsiz = totsiz / 1024
totsiz = (totsiz / 1024)+1
totsiz = (totsiz / 1024)+1
freeSpace = freeSpace / 1024
freeSpace = (freeSpace / 1024) + 1
freeSpace = (freeSpace / 1024) + 1
MessageBox.Show(totsiz.ToString)
MessageBox.Show(freeSpace.ToString)
End If
Next
Give me some logic to get the freespace as well as total size for a server..
Re: Total/Free Space in Drive
It's not good code but I did it some years ago by shelling out to a
batch file containing:
cscript ListFreeDiskSpace.wsf /list:servers.txt /log:lfds.log /output:lfds.out
I "think" that now you should be looking at WMI/windows instrumentation but
I've never done that.
1 Attachment(s)
Re: Total/Free Space in Drive
OOPs. Forgot the .wsf file.