I have a web application that I’ll be distributing to customers. I’ll give them the option of backing up and restoring the back-end SQL Server database through an admin web page.
For backup I just programmatically create a file name using time-stamps and let SQL Server save it in the default backup folder. For restoring, I’d like to list the backup files and let the user choose which one to use, but I don’t know what the default backup folder is to get a file listing.
How can I programmatically obtain the default backup folder for SQL Server 2008 Express R2 using C#?
Thanks
I ended up using the following SqlCommand … This solution appeared in another answer that was for some reason erased.? Anyway, here is the command I ended up using:
And here is the command in my C# code which shows the default backup folder path getting stored in the variable backupFolder: