0

How to get enumfiles method in DMO in SMO

means if i pass the master datafil;es to a method then it wil return the corresponding datafile path and logfile path. is there is any such method in SMO ??

for ex:in DMo Enumfiles(master) then it wil return corr filepath . is such method in SMO

Plz Help me..

Cute
  • 13,643
  • 36
  • 96
  • 112

1 Answers1

1

You can use the Server Databases FileGroups Files collections like this:

public void GetFileNames(string servername, string databasename)
{
    Server s = new Server(servername);
    foreach (FileGroup fg in s.Databases[databasename].FileGroups)
    {
        foreach (DataFile df in fg.Files)
            Console.WriteLine(df.FileName);
    }
}
Jonathan Kehayias
  • 3,402
  • 1
  • 23
  • 23
  • This returns only the data files. To get the path of the logfiles, you can query `s.Databases[databasename].LogFiles`. – Heinzi Jul 25 '11 at 14:48