日期:2014-05-18  浏览次数:20731 次

备份 数据库问题!会的来,在线等,解决即结帖!
(我连局域网服务器)我在c#程序里写了数据库备份代码?备份成功了,但是文件在服务器上而没在本地上,.bar文件字服务器上,   怎样才能备份的时候让他备份到本地计算机上呢?

------解决方案--------------------
up
------解决方案--------------------
貌似米有办法直接备份到别的机器上

只能在备份完后 通过别的方式传到本地 这就需要权衡一下了 因为通常一个数据库的备份会很大哦
------解决方案--------------------
可以考虑用流的方式提供下载

/// <summary>
/// 以流的方式提供下载
/// </summary>
/// <param name= "path "> 文件路径 </param>
protected void DownLoad(string path)
{
FileInfo file = new FileInfo(path);
Response.Clear();
Response.ClearHeaders();
Response.Buffer = false;
Response.ContentType = "application/octet-stream ";
Response.AppendHeader( "Content-Disposition ", "attachment;filename= " + HttpUtility.UrlEncode(file.FullName, System.Text.Encoding.UTF8));
Response.AppendHeader( "Content-Length ", file.Length.ToString());
Response.WriteFile(file.FullName);
Response.Flush();
Response.End();
}
------解决方案--------------------
恩 需要自己写网络模块进行传输
------解决方案--------------------
文件太大时不宜! 
备份路径可以设为共享如 \\202.101.100.99\data\bk20070822.bak
------解决方案--------------------
备份时只能是本地