Home > DeveloperSection > Forums > use openfiledialog to get path of open database C#
Babe Zaharias
Babe Zaharias

Total Post:19

Posted on    September-28-2013 8:07 AM

 C# C# 

 1 Reply(s)
 1282  View(s)
Rate this:
I'm using Visual Studio Expess 2010. I am trying to figure out how to use the openfiledialog to getthe path of my database.

Currently I close the connection to my database and then try to select the database in the open file dialog but Windows tells me: "This file is in use, close the file..."

If I've closed my db connection what else do I need to do to completely close the file so I can select it in the openfiledialog?

It can depend a lot on where the db file is, e.g. is it in your project? is it in your sql server data folder?

Ida B Wells
Ida B Wells

Total Post:30

Posted on    September-28-2013 9:03 AM

Hello Babe!

Try the following sql to give you the path if it's in the data folder...

select physical_name
from sys.database_files
where type = 0

if it's in the app_data folder of your project try a simple


Don't want to miss updates? Please click the below button!

Follow MindStick