更改try catch逻辑

This commit is contained in:
ZtRXR 2023-10-14 12:57:12 +08:00
parent 3a3f866bf4
commit c07715536c

View File

@ -3,8 +3,6 @@ using CopyUSB.MyDB;
using System.Diagnostics; using System.Diagnostics;
using System.Management; using System.Management;
try
{
static string GetVolumeLabel(string driveName) static string GetVolumeLabel(string driveName)
{ {
try try
@ -27,6 +25,8 @@ try
managementEventWatcher.EventArrived += (s, e) => managementEventWatcher.EventArrived += (s, e) =>
{
try
{ {
/*Console.WriteLine("触发器被触发了");*/ /*Console.WriteLine("触发器被触发了");*/
string driveName = e.NewEvent.Properties["DriveName"].Value.ToString(); string driveName = e.NewEvent.Properties["DriveName"].Value.ToString();
@ -110,6 +110,10 @@ try
/*Console.WriteLine($"元素个数{sortedList.Count()}");*/ /*Console.WriteLine($"元素个数{sortedList.Count()}");*/
Debug.WriteLine("\n--------------Scaned and waiting--------------\n"); Debug.WriteLine("\n--------------Scaned and waiting--------------\n");
}catch(Exception ex)
{
Debug.WriteLine(ex.ToString());
}
}; };
managementEventWatcher.Start(); managementEventWatcher.Start();
@ -120,7 +124,3 @@ try
Thread.Sleep(1000); Thread.Sleep(1000);
/*Console.WriteLine("一次休眠周期");*/ /*Console.WriteLine("一次休眠周期");*/
} }
}catch(Exception ex)
{
Debug.WriteLine(ex.ToString());
}