2013-07-15 21 views
0

我試圖打電話與(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); 
     } 
    } 
} 
+0

這意味着你有2種方法用在相同的簽名同樣的範圍。所以只需將任何一種方法的名稱更改爲EmptyFolderContents_New – Ehsan

+0

提供完整的錯誤消息。這意味着在同一個類中有另一個具有相同名稱/參數的方法 – CodingIntrigue

+0

聽起來像Windows無法判斷您是否嘗試刪除該文件夾中的快捷方式(.lnk文件)或快捷方式指向的文件。我會小心這個。 – tgolisch

回答

0

這意味着你已經在相同範圍有2種方法具有相同簽名。無論是從範圍中刪除不需要的方法或改變任何一個方法的名稱的東西

 private void EmptyFolderContents_New(string folderName) 

然後調用它像這樣

 EmptyFolderContents_New(recent); 
+0

謝謝,我找到了同名的方法,我不知道它是如何到達那裏的:O.無論如何感謝(: – Candie

+0

@Candie馬克它作爲答案然後:) – Ehsan

+0

我會(:必須等待5分鐘雖然 – Candie

相關問題