首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

检测到无法访问的代码!解决方案

2012-09-28 
检测到无法访问的代码!//先判断目标目录是否是源目录的子目录for (DirectoryInfo temp destination.Pare

检测到无法访问的代码!
//先判断目标目录是否是源目录的子目录
  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;
}
}

热点排行