我正在研究c#中的一个项目,该项目使用线程来初始化对xcopy的多个调用,以将用户目录从一个工作站复制到网络位置。
当我在调试模式下运行程序时,有时如果我有一个断点,在程序遇到对XCopy的调用之前,我用停止按钮停止调试(在VS 2010中),程序将继续调用XCopy函数,即使我阻止它到达代码中的调用。如果我在foreach循环内停止,调试器会继续执行其他foreach实例吗?
我知道这听起来很疯狂,但还有其他人经历过这种情况,或者您是否可以提供一些可以纠正这种情况的建议?
第二个问题是当我从Win7机器上运行它访问Firefox中的XP机器时,osInfo是正确的,但是当我的老板在IE中的Win7机器上运行它时,它不起作用。这条线路对我来说很有意义:
System.OperatingSystem osInfo = System.Environment.OSVersion;
if (dir_base.Exists && (osInfo.Platform == System.PlatformID.Win32NT)) //XP
应该拉动运行代码的系统,而不是网络位置的操作系统类型,但if语句在运行时结果为true而在执行时为false ...
这是我的代码:
public static void BuildSources_Targets(string Source, string str_Target )
{
//XP:
string str_basePath = Path.Combine(Source, "Documents and Settings");
var dir_base = new DirectoryInfo(str_basePath);
System.OperatingSystem osInfo = System.Environment.OSVersion;
if (dir_base.Exists && (osInfo.Platform == System.PlatformID.Win32NT)) //XP
{
foreach (var dir in dir_base.GetFileSystemInfos())
{
switch (dir.ToString())
{
case "administrator":
case "Administrator":
case "Default User":
case "All Users":
//Do nothing
break;
default:
string str_dir = dir.ToString();
//Handle XP App Data
//str_baseAndDirsPath = Path.Combine(dir_base.ToString(), str_dir, Environment.SpecialFolder.ApplicationData.ToString());
string str_baseAndDirsPath = Path.Combine(dir_base.ToString(), str_dir, "Application Data");
DirectoryInfo dir_baseAndDirs = new DirectoryInfo(str_baseAndDirsPath);
if (dir_baseAndDirs.Exists)
{
string str_Destination = Path.Combine(str_Target, str_dir, "Application Data");
ProcessXcopy(str_baseAndDirsPath, str_Destination);
}
//Handle XP Documents
str_baseAndDirsPath = Path.Combine(dir_base.ToString(), str_dir, "My Documents");
dir_baseAndDirs = new DirectoryInfo(str_baseAndDirsPath);
if (dir_baseAndDirs.Exists)
{
string str_Destination = Path.Combine(str_Target, str_dir, str_dir + " Documents");
ProcessXcopy(str_baseAndDirsPath, str_Destination);
}
break;
} //end of switch
} //end of foreach
} //end of dir_base.exists
//it continues from here...but that's enough to illustrate my problem...