Hi
Can any body plz tell me how to find the location where my data and log files stored using SMO in c#
Thanks in Advance
Hi
Can any body plz tell me how to find the location where my data and log files stored using SMO in c#
Thanks in Advance
apparently you can "get the names of the logical data and log files from the FileGroups and the Files collections."
see link text
public static void foo() {
Microsoft.SqlServer.Management.Smo.Server server = new ServerConnection("<server name>");
Microsoft.SqlServer.Management.Smo.Database db = server.Databases["<database name>"];
Console.WriteLine(db.FileGroups[0].Files[0].FileName);
Console.WriteLine(db.LogFiles[0].FileName);
}
This example assumes you have sufficient rights to the Server\Database, and only returns the full path\filename for the first db/log file in the filegroup.
FileGroups, Files, and LogFiles are SMO collections that will contain one or more of it's respective items.