Find available disk space using C#

WBOY
Release: 2023-09-06 10:29:02
forward
708 people have browsed it

使用 C# 查找可用磁盘空间

First, create an instance of DriveInfo-

DriveInfo dInfo = new DriveInfo("E");
Copy after login

Display available space-

Console.WriteLine("Disk Free space = {0}", dInfo.AvailableFreeSpace);
Copy after login

Now, use the AvailableFreeSpace property and get the percentage of free space-

Double pc = (dInfo.AvailableFreeSpace / (float)dInfo.TotalSize) * 100;
Copy after login

Here you will get the percentage of free size to total disk space -

Console.WriteLine(" Free space (percentage) = {0:0.00}%.", pc);
Copy after login

The above is the detailed content of Find available disk space using C#. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!