当前位置: 代码迷 >> ASP.NET >> asp.netc#怎么在线备份、还原Access数据库?
  详细解决方案

asp.netc#怎么在线备份、还原Access数据库?

热度:8787   发布时间:2013-02-25 00:00:00.0
asp.netc#如何在线备份、还原Access数据库??
asp.netc#如何在线备份、还原Access数据库??

------解决方案--------------------------------------------------------
把当前文件copy到别处一份不就行了。

下面的示例将文件复制到指定路径,不允许改写同名的目标文件。
C# code
using System;using System.IO;class Test {    public static void Main()     {        string path = @"c:\temp\MyTest.txt";        string path2 = path + "temp";        try         {            using (FileStream fs = File.Create(path)) {}            // Ensure that the target does not exist.            File.Delete(path2);            // Copy the file.            File.Copy(path, path2);            Console.WriteLine("{0} copied to {1}", path, path2);            // Try to copy the same file again, which should fail.            File.Copy(path, path2);            Console.WriteLine("The second Copy operation succeeded, which was not expected.");        }         catch (Exception e)         {            Console.WriteLine("Double copying is not allowed, as expected.");            Console.WriteLine(e.ToString());        }    }}
  相关解决方案