0

我已经备份了 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");
            }
4

0 回答 0