假设 UAC 为 ON。这不会产生关闭它的问题。
我有具有备份/恢复功能并使用 sql server 2005 express 的 ac# 应用程序。
获取 backupPath 的代码用于备份和还原,所有用途的名称都是 backup.dat
生成备份路径
string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
path = Path.Combine(path, "CompName");
if(!Directory.Exists(path))
Directory.CreateDirectory(path);
path = Path.Combine(path, "AppName");
if(!Directory.Exists(path))
Directory.CreateDirectory(path);
return path;
备份时,db 在 **C:\ProgramData\CompName\AppName** 中生成 backup.dat,并且从该位置压缩到用户选择的目标目录没有任何困难。
恢复时,获取存档目录或文件没有问题,但解压缩时会转到 **C:\Users\UserName\AppData\Local\VirtualStore\ProgramData\CompName\AppName**
我需要知道为什么我的解压缩文件会进入虚拟存储,以便我可以恢复数据库,因为根据我对 vista sql server 编程的理解,不应该/将无法访问该虚拟存储路径。
编辑:未能提供减压 - 我认为这不是问题,但问题就在这里。
private void DecompressArchiveFile(string compressedFile, string backupPath)
{
GZipStream gzip = new GZipStream(new FileStream(compressedFile, FileMode.Open, FileAccess.Read, FileShare.None), CompressionMode.Decompress, false);
FileStream fs = new FileStream(backupPath, FileMode.Create, FileAccess.Write, FileShare.None);
byte[] buffer = new byte[10000];
int count = -1;
while (count != 0)
{
count = gzip.Read(buffer, 0, 10000);
fs.Write(buffer, 0, count);
}
gzip.Close();
fs.Close();
}
感谢您的所有帮助-TK