driveinfo

How can I determine free space on a Windows CE device?

喜你入骨 提交于 2020-01-17 04:17:11
问题 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 work, which I adapted as: internal static bool EnoughStorageSpace(long spaceNeeded) { DriveInfo[] allDrives = DriveInfo.GetDrives(); long freeSpace = 0; foreach (DriveInfo di in allDrives) { if (di.IsReady) { freeSpace = di.AvailableFreeSpace; } }

System.IO.DriveInfo returns wrong disk space values

£可爱£侵袭症+ 提交于 2020-01-04 19:48:48
问题 UPDATE : This issue doesn't appear on Android devices I've tested. It returns good values. Would really appreciate any pointers on this matter. I am having trouble getting the correct AvailableFreeSpace values from my Mac desktop computer. I am working with Unity3D C#, and am using the following code : DriveInfo[] drives = DriveInfo.GetDrives(); foreach(DriveInfo drive in drives) { if (drive.IsReady) { Debug.Log(drive.Name); Debug.Log(drive.AvailableFreeSpace); Debug.Log(drive.TotalFreeSpace)

How to get drive information by volume id

痴心易碎 提交于 2019-12-22 04:30:12
问题 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 Removable/local disk It doesn't matter how the info is retrieved (it could be script, cpp ,c#, java code). EDIT: I tried to use DriveInfo, Win32_LogicalDisk, Win32_Volume, Win32_PnpDevices - but I couldn't find this weird id... in all cases the id has a

DriveInfo.GetDrives() not returning mapped drives when run as administrator

爱⌒轻易说出口 提交于 2019-12-19 03:41:27
问题 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 ((i.Name.Contains("V")) && (i.IsReady)) { result = true; break; } } The mapped drives are mapped fro all users. The code above works fine when run as a regular user, however is Visual Studio 2010 is run as administrator the GetDrives method only returns the Fixed drives

Map a DiskIndex to a Volume Label

自闭症网瘾萝莉.ら 提交于 2019-12-11 07:53:57
问题 Current I am able to get all the Drives and their labels in c# by using the DriveInfo.GetDrives(). Then I am able to get the Disk Index / Index of the Partition by this methodology. var searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_DiskPartition"); foreach (var queryObj in searcher.Get()) { Console.WriteLine("-----------------------------------"); Console.WriteLine("Win32_DiskPartition instance"); Console.WriteLine("Name:{0}", (string)queryObj["Name"]); Console

Get available disk space in Unity

回眸只為那壹抹淺笑 提交于 2019-12-11 01:10:40
问题 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 Directory.GetLogicalDrives()); ... But that doesn't get me anywhere in terms of free space. ORIGINAL QUESTION : I am working in Unity C#. I'd like to get the free available disk space on the device I'm using. I've tried using System.IO.DriveInfo but it doesn't work

Getting drive info from a remote computer

China☆狼群 提交于 2019-12-10 15:11:20
问题 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 driveInfo using IO namespace. but how to combine them? 回答1: Use the System.Management namespace and Win32_Volume WMI class for this. You can query for an instance with a DriveLetter of C: and retrieve its FreeSpace property as follows: ManagementPath

Set Drive VolumeLabel

好久不见. 提交于 2019-12-10 13:18:37
问题 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 sample I would really appreciate it. Here is what i currently have: DriveInfo[] allDrives = DriveInfo.GetDrives(); foreach (DriveInfo d in allDrives) { if (d.IsReady && d.DriveType == DriveType.Removable) { //set volume label here } } 回答1: Thanks James!

Best way to detect dvd insertion in drive c#

和自甴很熟 提交于 2019-12-06 13:40:26
问题 I tried using WMI to detect new media insertion in Disk Drive using following code. But is there managed solution like using loop in background thread with DriveInfo.GetDrives? Which is best way to do this? I'm getting 'Disk is not in the drive please insert disk' dialog with abort, retry and continue button on other pc when i tried the following code? On may machine it works fine. private void DriveWatcher() { try { var wqlEventQuery = new WqlEventQuery { EventClassName = "_

How to get drive information by volume id

我的未来我决定 提交于 2019-12-05 05:07:45
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 Removable/local disk It doesn't matter how the info is retrieved (it could be script, cpp ,c#, java code). EDIT: I tried to use DriveInfo, Win32_LogicalDisk, Win32_Volume, Win32_PnpDevices - but I couldn't find this weird id... in all cases the id has a differrent format UPDATE: Found out how to do it. you can enumerate Win32_Volume like this: