日期:2014-05-17  浏览次数:20489 次

检测到无法访问的代码!
//先判断目标目录是否是源目录的子目录
  for (DirectoryInfo temp = destination.Parent; temp != null; temp = temp.Parent )
  {
  if (temp.FullName == source.FullName)
  MessageBox.Show("目标目录是源目录的子目录!无法复制!", "Eroor", MessageBoxButtons.OK, MessageBoxIcon.Error);
  return;
  }

这段代码在另一个程序里都不报错,在我这边,temp = temp.Parent下面就显示“检测到无法访问的代码”。在线等!!!

------解决方案--------------------
for (DirectoryInfo temp = destination.Parent; temp != null; temp = temp.Parent )
{
if (temp.FullName == source.FullName)
{
MessageBox.Show("目标目录是源目录的子目录!无法复制!", "Eroor", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}