我有一句臺詞: string[] cPathDirectories = Directory.GetDirectories(Properties.Settings.Default.customerFolderDirectory);
自定義錯誤
,將拋出錯誤「路徑不是法律形式」,如果用戶沒有指定的搜索路徑(此設置保存爲String.Empty在這一點上)。我想拋出這個錯誤,說:「嘿,你白癡,進入應用程序設置,並指定一個有效的路徑」,而不是。有沒有辦法做到這一點,而不是:
...catch (SystemException ex)
{
if(ex.Message == "Path is not of legal form.")
{
MessageBox.Show("Hey you idiot, go into the application settings and specify a valid path","Error");
}
else
{
MessageBox.Show(ex.Message,"Error");
}
}
對用戶說這是一個非常愚蠢的事情。 – SLaks