运行这段 C#代码报错,错误原因定位不了。请问可能是什么原因。
//css_reference Microsoft.VisualBasic.dll;
// 引用必要的命名空间
using System.Windows.Forms;
using System.Collections.Generic;
// Quicker将会调用的函数
public static void Exec(Quicker.Public.IStepContext context)
{
var model = context.GetVarValue("model");
List<string> path = (List<string>)(context.GetVarValue("path"));
foreach (string i in path)
{
if (model == "recycleBin")
{
if (File.Exists(i))
{
Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(i, Microsoft.VisualBasic.FileIO.UIOption.OnlyErrorDialogs,Microsoft.VisualBasic.FileIO.RecycleOption.SendToRecycleBin);
}
else
{
Microsoft.VisualBasic.FileIO.FileSystem.DeleteDirectory(i, (Microsoft.VisualBasic.FileIO.DeleteDirectoryOption)Microsoft.VisualBasic.FileIO.RecycleOption.SendToRecycleBin);
}
}
else
{
if (File.Exists(i))
{
Microsoft.VisualBasic.FileIO.FileSystem.DeleteFile(i);
}
else
{
Microsoft.VisualBasic.FileIO.FileSystem.DeleteDirectory(i, (Microsoft.VisualBasic.FileIO.DeleteDirectoryOption)Microsoft.VisualBasic.FileIO.RecycleOption.DeletePermanently);
}
}
}
}