我試圖打電話與(recent
)系統變量的方法(EmptyFolderContents
),但我得到這個消息:「的號召不明確」(調用具有相同數據結構的方法)
該呼叫在以下方法或屬性之間不明確
那麼,如何重命名/更改此?
String recent = Environment.ExpandEnvironmentVariables("%USERPROFILE%") + "\\Recent";
EmptyFolderContents(recent);
private void EmptyFolderContents(string folderName)
{
foreach (var folder in Directory.GetDirectories(folderName))
{
try
{
Directory.Delete(folder, true);
}
catch (Exception excep)
{
System.Diagnostics.Debug.WriteLine(excep);
}
}
foreach (var file in Directory.GetFiles(folderName))
{
try
{
File.Delete(file);
}
catch (Exception excep)
{
System.Diagnostics.Debug.WriteLine(excep);
}
}
}
這意味着你有2種方法用在相同的簽名同樣的範圍。所以只需將任何一種方法的名稱更改爲EmptyFolderContents_New – Ehsan
提供完整的錯誤消息。這意味着在同一個類中有另一個具有相同名稱/參數的方法 – CodingIntrigue
聽起來像Windows無法判斷您是否嘗試刪除該文件夾中的快捷方式(.lnk文件)或快捷方式指向的文件。我會小心這個。 – tgolisch