In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what is the method of C # Windows application". In daily operation, I believe that many people have doubts about what the method of C # Windows application is. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubt of "what is the method of C # Windows application?" Next, please follow the editor to study!
We use Visual Studio 2005 to create the sample program. First, create a blank project of the C # Windows application and name the solution and project GetLogicDrives. On the default Form1 form, we each place a ListView and a Button control, leaving the default name of the control unchanged, set the View property of ListView1 to Details, double-click the Columns property of ListView1, and add five columns for the details view, namely: disk letter, volume label, type, capacity and free space. Set the Text property of Button1 to Refresh to add a click event for the Button1
The code of the C # Windows application is as follows:
Private void button1_Click (object sender, EventArgs e) {listView1.Items.Clear (); SelectQuery selectQuery = new SelectQuery ("select * from win32_logicaldisk"); ManagementObjectSearcher searcher = new ManagementObjectSearcher (selectQuery); int item0; foreach (ManagementObject disk in searcher.Get ()) {/ / disk letter listView1.Items.Add (disk ["Name"]. ToString ()); / / Volume label try {listView1.Items.Add (disk ["VolumeName"]. ToString ()) } catch {listView1.Items[ I] .SubItems.Add ("device not ready");} / / Drive type string DriveType; try {DriveType = disk ["DriveType"]. ToString (); switch (DriveType) {case "0": listView1.Items.SubItems.Add ("unknown device"); break; case "1": listView1.Items[ I] .SubItems.Add ("not partitioned"); SubItems.Add ("not partitioned") Case "2": listView1.Items[ I] .SubItems.Add ("removable disk"); break; case "3": listView1.Items[ I] .SubItems.Add ("hard disk"); break; case "4": listView1.Items [I] .SubItems.Add ("network drive"); break; case "5": listView1.Items[ I] .SubItems.add ("CD-ROM"); break Case "6": listView1.Items[ I] .SubItems.Add ("memory disk"); break;}} catch {listView1.Items.Add ("unknown type");} / / capacity try {listView1.Items [I] .SubItems.Add (GetSizeUseUnit (disk ["Size"]. ToString ());} catch {listView1.Items [I] .SubItems.Add ("device not ready") } / / remaining space try {listView1.Items[ I] .SubItems.Add (GetSizeUseUnit (disk ["FreeSpace"]. ToString ());} catch {listView1.Items.SubItems.Add ("device not ready");} itemsAdd;} items.Add;} at this point, the study of "what is the method of C# Windows application" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.