我想在他们的特定文件夹中传输txt和sql extentions文件。在下面的方法中,第一个createdirectory运行良好,但是第二个给出了IOException错误,并且说我已经有一个同名的文件夹了。
我想念什么?
private void InstallProgram()
{
string _sql = "sql";
string _txt = "txt";
DirectoryInfo d = new DirectoryInfo(executpath);
string destdir = Path.Combine(executpath,_sql);
Directory.CreateDirectory(destdir); // This works
string[] filebox = Directory.GetFiles(executpath, "*." + _sql);
foreach(var item in filebox)
File.Move(item,Path.Combine(destdir,Path.GetFileName(item)));
destdir = Path.Combine(executpath, _txt);
Directory.CreateDirectory(destdir); // Where I get the error
filebox = Directory.GetFiles(executpath, "*." + _txt);
foreach (var item in filebox)
File.Move(item,Path.Combine(destdir,Path.GetFileName(item)));
}