Get the Disk drive information in vb.net

I want to know the free space, used space in the particular drive of my hard disk by vb.net program.

so can anyone help me in this issue




Answer this question

Get the Disk drive information in vb.net

  • Lasse Thomsen

    sure.

    in .NET 2.0 there is a DriveInfo class in the System.IO namespace

     



    For Each curDrive as DriveInfo in My.Computer.FileSystem.Drives
       If curDrive.DriveType = DriveType.Fixed Then
          dim theFreeSpace as long = curDrive.AvailableFreeSpace
          MessageBox.Show(theFreeSpace.ToString())
       End if
    Next

     

    You can of course get the name of the drive using the name property to check to see if it is the drive you are after

    does this help



  • ARGroupIT

    Thanks frined

    Its worked.



  • gwong685

    I got an error running this code can you pleas help

    how i define curDrive

     


  • llkoolj

    woops, my mistake!

    should be:

    For Each curDrive As DriveInfo In My.Computer.FileSystem.Drives

    ..

    ..



  • JonH66

    glad I could help! :-)

  • Get the Disk drive information in vb.net