Results 1 to 3 of 3

Thread: Total/Free Space in Drive

  1. #1

    Thread Starter
    Fanatic Member vijy's Avatar
    Join Date
    May 2007
    Location
    India
    Posts
    548

    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..
    Visual Studio.net 2010
    If this post is useful, rate it


  2. #2
    Lively Member
    Join Date
    Sep 2002
    Posts
    77

    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.

  3. #3
    Lively Member
    Join Date
    Sep 2002
    Posts
    77

    Re: Total/Free Space in Drive

    OOPs. Forgot the .wsf file.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width