none
AvailableFreeSpace RRS feed

  • Question

  • Hi,

    https://docs.microsoft.com/en-us/dotnet/api/system.io.driveinfo.availablefreespace?view=netframework-4.8

    DriveInfo.AvailableFreeSpace("C:\") is not the right usage, and everywhere the sample of AvailableFreeSpace is just using it in a GetDrives For Each loop!

    I don't know how to use it not in a loop, and just for a single drive, to get the available space of C:\ for example.

    Thanks for advise.


    • Edited by OSVBNET Sunday, May 5, 2019 11:12 PM
    Sunday, May 5, 2019 11:11 PM

Answers

  • Hi

    Do you mean something like this?

    ' Form1 with multiline TextBox1
    Option Strict On
    Option Explicit On
    Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            For Each d As IO.DriveInfo In IO.DriveInfo.GetDrives()
                TextBox1.AppendText(d.Name & vbTab & d.AvailableFreeSpace)
            Next
        End Sub
    End Class


    Regards Les, Livingston, Scotland


    • Edited by leshay Sunday, May 5, 2019 11:28 PM
    • Marked as answer by OSVBNET Sunday, May 5, 2019 11:46 PM
    Sunday, May 5, 2019 11:27 PM

All replies

  • Hi

    Do you mean something like this?

    ' Form1 with multiline TextBox1
    Option Strict On
    Option Explicit On
    Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            For Each d As IO.DriveInfo In IO.DriveInfo.GetDrives()
                TextBox1.AppendText(d.Name & vbTab & d.AvailableFreeSpace)
            Next
        End Sub
    End Class


    Regards Les, Livingston, Scotland


    • Edited by leshay Sunday, May 5, 2019 11:28 PM
    • Marked as answer by OSVBNET Sunday, May 5, 2019 11:46 PM
    Sunday, May 5, 2019 11:27 PM
  • Yes and no, thanks for the tip I found it :)
    Sunday, May 5, 2019 11:46 PM