Example #1
0
        /// <summary>
        /// 备份数据库
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_BackUp_Click(object sender, RoutedEventArgs e)
        {
            string path = System.AppDomain.CurrentDomain.BaseDirectory + "test.bat";
            string currentDBFilePath = System.AppDomain.CurrentDomain.BaseDirectory + "test.sdf";

            if (!System.IO.File.Exists(path))
            {
                string newpath      = FileHelper.GetConfigString("defaultPath");
                string writeContent = string.Format(@"copy " + currentDBFilePath + " " + newpath);
                BatHelper.WriteBat(path, writeContent);
            }
            if (BatHelper.RunBat(path))
            {
                System.Windows.MessageBox.Show("数据库备份成功!");
            }
        }
Example #2
0
 /// <summary>
 /// 路径选择
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Btn_OpenPath_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         string path = FileHelper.OpenFolderPath();
         TB_Path.Text = path;
         if (!string.IsNullOrWhiteSpace(path.Trim()))
         {
             string currentBatFilePath = System.AppDomain.CurrentDomain.BaseDirectory + "test.bat";
             string currentDBFilePath  = System.AppDomain.CurrentDomain.BaseDirectory + "test.sdf";
             string writeContent       = string.Format(@"copy " + currentDBFilePath + " " + path);
             BatHelper.WriteBat(currentBatFilePath, writeContent);
         }
     }
     catch (Exception ex)
     {
     }
 }