我正在尝试EmptyFolderContents
使用 ( recent
) 系统变量调用方法 ( ),但收到以下消息:
以下方法或属性之间的调用不明确
那么我该如何重命名/更改它呢?
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);
}
}
}