How to: Determine a Drive's Physical Free Space in Visual Basic
The GetDriveInfo method provides a DriveInfo object that can be queried for information about a drive on a computer. You can use the TotalFreeSpace property to determine the amount of space on a drive. Attempting to access the property without sufficient permission throws a SecurityException exception.
Note |
|---|
|
Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings. |
To determine the amount of free space on a drive
Use the TotalFreeSpace property to determine the amount of free space, as illustrated in the following code:
This code example is also available as an IntelliSense code snippet. In the code snippet picker, it is located in File system - Processing Drives, Folders, and Files. For more information, see How to: Insert IntelliSense Code Snippets.
Note