views:

197

answers:

1

Hi

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..

A: 

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