当前位置:数据库 > SQLServer >>

c#写的sql Server数据库自动备份程序

这几天写了一个xp下安装sql Server 2005 express版本的数据库自动备份程序,大家看看若是有觉得不合理的地方欢迎指正

[csharp]
 
[csharp] 
 
[csharp] 
using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Text; 
using System.Windows.Forms; 
using System.IO; 
using System.Xml; 
using Microsoft.Win32; 
using System.Diagnostics; 
 
 
namespace CPU卡表数据库备份程序 

    public partial class Config : Form 
    { 
        public Config() 
        { 
            InitializeComponent(); 
        } 
 
 
        private void Config_Load(object sender, EventArgs e) 
        { 
            //this.Cb_Hour.SelectedIndex = 0; 
            //this.Cb_Minute.SelectedIndex = 0; 
            string Dir_Source = GetValue("Dir"); 
            this.Txt_DirSource.Text = Dir_Source; 
            string Hour = GetValue("Hour").Trim(); 
            string Minute = GetValue("Minute").Trim(); 
            this.Cb_Hour.Text = Hour; 
            this.Cb_Minute.Text = Minute; 
            string AutoRun = GetValue("AutoRun"); 
            if (AutoRun.Trim() == "false") 
            { 
                this.CheckBox_AutoRun.Checked = false; 
            } 
            else 
            { 
                this.CheckBox_AutoRun.Checked = true; 
            } 
        } 
 
 
        private void Txt_DirSource_MouseClick(object sender, MouseEventArgs e) 
        { 
            FolderBrowserDialog dialog = new FolderBrowserDialog(); 
            dialog.Description = "请选择备份路径"; 
            if (dialog.ShowDialog() == DialogResult.OK) 
            { 
                this.Txt_DirSource.Text = dialog.SelectedPath; 
            } 
            else 
            { 
                return; 
            } 
        } 
 
 
        private void Btn_SetDir_Click(object sender, EventArgs e) 
        { 
            //首先判断目录是否存在 
            string Dir_Source = this.Txt_DirSource.Text.Trim(); 
            if (Dir_Source == "" || Directory.Exists(Dir_Source) == false) 
            { 
                MessageBox.Show("备份目录设置有误,请查证", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); 
                return; 
            } 
            else 
            { 
                SetValue("Dir", Dir_Source); 
                MessageBox.Show("备份目录设置为"+Dir_Source,"提示",MessageBoxButtons.OK,MessageBoxIcon.Information); 
                return; 
  
            } 
             
        } 
        /// <summary> 
        /// 设置程序开机启动 
        /// 或取消开机启动 
        /// </summary> 
        /// <param name="started">设置开机启动,或者取消开机启动</param> 
        /// <param name="exeName">注册表中程序的名字</param> 
        /// <param name="path">开机启动的程序路径</param> 
        /// <returns>开启或则停用是否成功</returns> 
        public static bool runWhenStart(bool started, string exeName, string path) 
        { 
            RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);//打开注册表子项 
            if (key == null)//如果该项不存在的话,则创建该子项 
            { 
                key = Regis

补充:软件开发 , C# ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,