How can I determine the default data and log file locations of a Smo.Server instance?
For example, my server's default location is "C:\Program Files\Microsoft SQL Server\MSSQL\Data"
Hi,
you can use the following code to get the registry values, but the documentation is not right at this point as I won′t bring back any string if not set in the registry:
Server s = new Server(".");
Console.WriteLine(s.Settings.DefaultFile);
Jens K. Suessmeyer.
http://www.sqlserver2005.de
|||
Thanks - thats what I was looking for. When the registry value is not set I will just grab the file location of the master db:
'open the master database
Dim master As Database = New Database(_server, "master")
master.Refresh()
'get the location of its mdf file
Dim masterMdfFilename = master.FileGroups.Item(0).Files.Item(0).FileName
Console.WriteLine(System.IO.Path.GetDirectoryName(masterMdfFilename))
No comments:
Post a Comment