0

I am afraid that i am unable to locate the absolute path of the SQL SERVER data files.

I have tried to so do by doing the following.

    foreach( Database db in srv.Databases)
     string filepath=db.PrimaryFilepath;
     string name=db.Name;
     abspth=filepath+"//"+name+".mdf";

Like this i have workaround.But is there is any alternative to get the absolute path.

But in case of logfiles it gives absolute path.......

Help me in this regard...

Thanks in Advance.

1 Answer 1

2

The Database in SMO should contain a Filegroups collection which in turn contains a Files collection - you should find your file path's in there.

        foreach(FileGroup fg in db.FileGroups)
        {
            foreach(DataFile df in fg.Files)
            {
                Console.WriteLine("File path: {0}", df.FileName);
            }
        }

Marc

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.