无法从.bak文件还原数据库

时间:2013-07-23 10:07:20

标签: c#-4.0 sql-server-ce

我已经备份了sql server ce数据库,但我无法从中恢复。

   try
      {
          string fileName = "TapeDatabase.sdf";
          string sourcePath = backupPath;
          OpenFileDialog OFD = new OpenFileDialog();
          OFD.ShowDialog();
          string FN = OFD.FileName; 
          string restorePath =   Path.GetDirectoryName(System.Windows.Forms.Application.StartupPath);

          string sourceFile = System.IO.Path.Combine(FN);
          string destFile = System.IO.Path.Combine(restorePath, fileName);
          try
          {
           System.IO.File.Copy(sourceFile, destFile, true);
           MessageBox.Show("Database was successfully restored to: " + destFile, "Info");
          }
          catch(Exception epp)
            {
              MessageBox.Show("Database was not restored");
            }

0 个答案:

没有答案