Questions tagged [driveinfo]
51 questions
22
votes
8 answers
How to correctly convert filesize in bytes into mega or gigabytes?
I'm using the DriveInfo class in my C# project to retrieve the available bytes on given drives. How to I correctly convert this number into Mega- or Gigabytes? Dividing by 1024 will not do the job I guess. The results always differ from those shown…

Mats
- 14,902
- 33
- 78
- 110
21
votes
3 answers
How to get the list of removable disk in c#?
I want to get the list of removable disk in c#. I want to skip the local drives.
Because i want the user to save the file only in removable disk.

Anuya
- 8,082
- 49
- 137
- 222
13
votes
2 answers
How to get Drive Letter and Name (volume label)
I have a program that tells me all the hard disks/ usb's, but it only tells me the drive letter not the name. Here is what I have:
DriveInfo[] drives = DriveInfo.GetDrives();
Console.WriteLine("Detected Drives: ");
for(int i = 0; i <…

Jister13
- 183
- 2
- 2
- 6
10
votes
4 answers
How to get drive information by volume id
I have a txt file with volume id's in it.
I need to get drive info (drive letter, drive size, etc.) from the drive volume id (Windows):
the volume id is in the following format:
\\?\Volume{XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}
The drive can be…

user844541
- 2,868
- 5
- 32
- 60
9
votes
2 answers
Mapped network drives cannot be listed in C#
I am trying to list all local drives in my application, and DriveInfo.GetDrives give back the local drive letters, and I need the mapped drives too.
Currently I have: C:, D:, and G: (HDD), E: and F: (CD), and S: and Z: (mapped network drives). (Yes,…

Zolka
- 221
- 1
- 3
- 8
9
votes
3 answers
Getting drive info from a remote computer
I can view a remotly connected pc from this article:Remote Desktop using c-net . but i dont need it. I just have to connect with that pc and get the free space data of C drive. How could i do this? I can connect to a remote desktop. I can get…
user1865670
7
votes
2 answers
Set Drive VolumeLabel
I am working on a small utility where I would like to change the volume label on flash drives that are connected to the computer. I know that DriveInfo is capable of doing it but I am at a loss as for how to accomplish it. If anyone has a code…

Paxamime
- 203
- 2
- 7
5
votes
1 answer
How can I tell if an optical drive (not the disc) is a CD or DVD drive?
As stated in the title, I'm trying to determine if a drive DVD drive or a CD drive. Again, I am not asking about the media, I'm asking about the actual drive itself... the object pointed to by a DriveInfo class.
I'm thinking the DriveInfo class…

Mark A. Donohoe
- 28,442
- 25
- 137
- 286
5
votes
2 answers
DriveInfo.GetDrives() not returning mapped drives when run as administrator
I'm creating a WPF app that among other things should check for the existence of several mapped drives. The code is straightforward:
DriveInfo[] systemDrives = DriveInfo.GetDrives();
foreach (DriveInfo i in systemDrives)
{
if…

LPena
- 51
- 1
- 2
4
votes
1 answer
See the AvailableFreeSpace of drives via IP-Address
I know that, AvailableFreeSpace is possible to use for local drives such as "C:/", "D:/" etc.
It also works on network drives.
But now my question is:
Is it possible to view the AvailableFreeSpace of a "Folder" on another IP?
I connect to the local…

Evosoul
- 197
- 1
- 12
3
votes
3 answers
.Net DriveInfo() with UNC paths?
Good morning,
is there a way to get a DriveInfo instance for UNC paths (e.g. "\fors343a.ww123.somedomain.net\folder\1\") because for example...
var driveInfo = new System.IO.DriveInfo(drive);
... throws an ArgumentException ("Object must be a root…

Jörg Battermann
- 4,044
- 5
- 42
- 79
3
votes
1 answer
LINQ enumeration of local dirves using DriveInfo
I know there are many ways to accomplish what I am trying to do here, but I wanted to try it with LINQ, and am seeing some odd (to me) results. Hoping someone here has some wisdom to offer me.
Goal is to find the drive on the local machine where we…

joebalt
- 969
- 1
- 12
- 24
3
votes
0 answers
Get available disk space in Unity
UPDATE : I have found a solution for the iOS and Android versions, however, I'm still getting this error when building for Mac and Windows. I've seen a workaround that only gets me the name of the drives :
foreach (string drive in…

Bypp
- 331
- 3
- 22
2
votes
2 answers
Is there a way to disable the write behind caching policy on a disk drive programmatically using C# in windows?
I need to remove write behind caching on the disk drives of our servers. Doing so in windows ==> Device Manager ==> Disk Drives ==> (right click) Properties ==> Policies ==> (CheckBox) Enable write behind caching | is easy but windows re-enables it…

Blixem
- 59
- 6
2
votes
1 answer
How can I determine free space on a Windows CE device?
I need to determine how much free space there is on a Windows CE device, to conditionally determine whether a particular operation should proceed.
I thought Ken Blanco's answer here (which bears a striking similarity to the example yonder) would…

B. Clay Shannon-B. Crow Raven
- 8,547
- 144
- 472
- 862