利用反射访问类库中的文件路径并拷贝文件

来源:互联网 发布:b*算法Java 编辑:程序博客网 时间:2024/04/28 16:26
public void CopyDataBase(int num)
{
string codeBase = Assembly.GetAssembly(typeof(DataSynchronizationTest)).CodeBase;
string appPath = codeBase.Replace(@"file:///", string.Empty);
appPath = appPath.Replace(@"/", @"\");
int indexBin = appPath.IndexOf("bin\\");
appPath = appPath.Substring(0, indexBin);
string localPath = appPath + "DbFiles\\" + DataBaseTestConfig.LocalDbFileName(num);
string serverPath = appPath + "DbFiles\\" + DataBaseTestConfig.ServerDbFileName(num);
string localDesPath = System.IO.Directory.GetCurrentDirectory() + "\\DbFiles\\" + DataBaseTestConfig.LocalDbFileName(num);
string serverDesPaht = System.IO.Directory.GetCurrentDirectory() + "\\DbFiles\\" + DataBaseTestConfig.ServerDbFileName(num);
File.Copy(localPath, localDesPath, true);
File.Copy(serverPath, serverDesPaht, true);
}
原创粉丝点击