views:

209

answers:

2

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

A: 

apparently you can "get the names of the logical data and log files from the FileGroups and the Files collections."

see link text

Gabe
No i want to know the exact path of log files in the system.
Cute
+1  A: 
 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.

C-Pound Guru