if (!File.Exists(A.mdb));
{ throw new Exception("源数据库不存在"); }
try { File.Copy(A.mdb, B.mdb2, true); }
catch (IOException ixp)
{ throw new Exception(ixp.ToString()); }
A.mdb这个应该是源数据库的绝对路径吧
我的ACCESS数据库放在了 D:\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\bin\Debug\pcdb.mdb,
我想把它备份到G盘跟目录下面,请问代码该如何去修改呢
{ throw new Exception("源数据库不存在"); }
try { File.Copy(A.mdb, B.mdb2, true); }
catch (IOException ixp)
{ throw new Exception(ixp.ToString()); }
A.mdb这个应该是源数据库的绝对路径吧
我的ACCESS数据库放在了 D:\My Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplication1\bin\Debug\pcdb.mdb,
我想把它备份到G盘跟目录下面,请问代码该如何去修改呢
用
string HomePath = System.Environment.CurrentDirectory;
//Application.StartupPath的上一级目录。
string TmpPath = HomePath.SubString(0,HomePath.LastIndexOf("\\")-1)
using System.IO;
winform
string HomePath = System.Environment.CurrentDirectory;
string TmpPath = HomePath.SubString(0, HomePath.LastIndexOf("\\") - 1); File.Copy(TmpPath+@"pcdb.mdb", @"G:\pcdb.mdb");web页面的话,是不可能有权限访问其他目录的
string RootPath = Server.MapPath("数据库文件的相对路径");
string virtualPath = RootPath + "/dbBackup/";
if (!Directory.Exists(virtualPath))
{
Directory.CreateDirectory(virtualPath);
}
File.Copy(RootPath + @"\pcdb.mdb",virtualPath + @"\pcdb.mdb");