File.Move, why do i get a FileNotFoundException? The file exist...
- by acidzombie24
Its extremely weird since the program is iterating the file! outfolder and infolder are both in H:/ my external HD using windows 7. The idea is to move all folders that only contain files with the extention db and svn-base. When i try to move the folder i get an exception. VS2010 tells me it cant find the folder specified in dir. This code is iterating through dir so how can it not find it! this is weird.
string []theExt = new string[] { "db", "svn-base" };
foreach (var dir in Directory.GetDirectories(infolder))
{
bool hit = false;
if (Directory.GetDirectories(dir).Count() > 0)
continue;
foreach (var f in Directory.GetFiles(dir))
{
var ext = Path.GetExtension(f).Substring(1);
if(theExt.Contains(ext) == false)
{
hit = true;
break;
}
}
if (!hit)
{
var dst = outfolder + "\\" + Path.GetFileName(dir);
File.Move(dir, outfolder); //FileNotFoundException: Could not find file dir.
}
}
}