简体   繁体   English

使用SMO查找要还原的备份文件

[英]Use SMO to locate a backup file to restore

I am able to use SMO to build a treeview similar to the Locate Backup File dialog from SSMS. 我能够使用SMO构建类似于SSMS的“定位备份文件”对话框的树视图。 I can list folders on the server, and if there are backup devices, those will be listed as well. 我可以在服务器上列出文件夹,如果有备份设备,也会列出这些文件夹。 One thing I can't seem to duplicate is how to browse for a backup file to restore that was not originally backed up from the server (so it's not in the list of backup devices). 我似乎无法复制的一件事是如何浏览备份文件以恢复最初未从服务器备份的备份文件(因此它不在备份设备列表中)。

I'm looking for something like this screenshot of the SSMS dialog: 我正在寻找类似SSMS对话框的截图: SSMS定位备份文件对话框

Is there an EnumServerFiles method similar to the Server.EnumDirectories() method? 是否有类似于Server.EnumDirectories()方法的EnumServerFiles方法?

Keep in mind, this may be running against a SQL Server that isn't the local machine (a network server). 请记住,这可能是针对不是本地计算机(网络服务器)的SQL Server运行的。

Don't try using SMO for this, just use a regular file system browse dialog. 不要尝试使用SMO,只需使用常规文件系统浏览对话框。

Edit: For a remote system, get the info you want with: 编辑:对于远程系统,获取所需的信息:

 exec xp_dirtree 'c:\sqlbackups\', 1, 1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM