私はこのエラーが発生しました管理者としてプログラムを実行しようとしましたが、まだこのエラーが出ません最近のドキュメントフォルダのショートカットを消去できない理由はありません。 :C#許可されていない例外
//this will delete the the files in the Recent Documents directory
private void DeleteRecentDocuments(string RecentDocumentsDirectory)
{
//this is the directory and parameter which we will pass when we call the method
DirectoryInfo cleanRecentDocuments = new DirectoryInfo(RecentDocumentsDirectory);
//try this code
try
{
//loop through the directory we use the getFiles method to collect all files which is stored in recentDocumentsFolder variable
foreach(FileInfo recentDocumentsFolder in cleanRecentDocuments.GetFiles())
{
//we delete all files in that directory
recentDocumentsFolder.Delete();
}
}
//catch any possible error and display a message
catch(Exception)
{
MessageBox.Show("Error could not clean Recent documents directory, please try again");
}
}
は、私は上記のこの方法が、あまりにも多くのそのだけのメソッドを呼び出し、パラメータがディレクトリであるDW試合を呼び出します。あなたが望むなら私はそれを投稿することができます。
役立つ
希望をテストしているコピーされます例外は何ですか? RecentDocumentsDirectory = @ "C:\ Users \ username \ Documents \ディレクトリ" –