When I write code in Windows C#, I don't understand the following:
System.IO.DriveInfo=newSystem.IO.DriveInfo("Z");
if(drive.IsReady)
{
strings;
s=string.Format ("{0:f1}GB/{1:f1}GB", drive.TotalFreeSpace/1024/1024/1024, drive.TotalSize/1024/1024/1024);
// hereinafter abbreviated
}
Do this every second
c# windows
Is there a way to find out how you're actually getting the value?
Implementation of System.IO.DriveInfo can be found at driveinfo.cs.
TotalFreeSpace
and TotalSize
appear to be specifications for the Windows API GetDiskFreeSpaceEx.
How GetDiskFreeSpaceEx
gets the information was not known from the API documentation.Contact Microsoft Support for more information.
Is there anything else I can do other than get it every second?
What's the purpose of getting it? USB memory or SD card removal detection?Network drive disconnection detection?Check disk space?Depending on that, I may be able to make another suggestion.
Checking the capacity of the connected USB memory every second means that the Safely Removed menu is not satisfactory, and it is the worst on the UX side.I don't think Oira would ever write a code like this.
If you want to detect the attachment and detachment of the drive name itself, simply handle the WM_DEVICECHANGE
and get the drive information.
http://d.hatena.ne.jp/ohyajapan/20081123/p1
CD/DVD/BLURAY media may have been removed from the drive WM_DEVICECHANGE
is available
https://support.microsoft.com/ja-jp/help/163503/how-to-receive-notification-of-cd-rom-insertion-or-removal
"Other than that, if you add ""why, what do you want to do"" in editing the original question, you may get a different answer."
538 Uncaught (inpromise) Error on Electron: An object could not be cloned
548 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
547 Who developed the "avformat-59.dll" that comes with FFmpeg?
712 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.