---
title: "use openfiledialog to get path of open database C#"  
description: "use openfiledialog to get path of open database C#"  
author: "Anonymous User"  
published: 2013-09-28  
updated: 2013-09-28  
canonical: https://www.mindstick.com/forum/1564/use-openfiledialog-to-get-path-of-open-database-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# use openfiledialog to get path of open database C#

I'm using [Visual Studio](https://www.mindstick.com/articles/12378/visual-studio-for-mac-is-out-of-beta-preview-now-officially-available) Expess 2010. I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to figure out how to use the openfiledialog to getthe path of my [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax).

Currently I [close the connection](https://www.mindstick.com/forum/87/how-use-the-dispose-method-for-close-the-connection) to my database and then try to select the database in the open file dialog but [Windows](https://www.mindstick.com/articles/311752/how-to-install-and-use-the-google-wifi-software-on-a-windows-or-mac-computer) 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](https://www.mindstick.com/forum/156583/best-way-to-link-bootstrap-file-in-your-project)? is it in your [sql server](https://www.mindstick.com/articles/12999/what-is-table-valued-function-in-sql-server) data folder?

## Replies

### Reply by Anonymous User

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](https://www.mindstick.com/articles/105927/how-to-excel-at-managing-multiple-projects) try a simple

```
Server.mappath
```


---

Original Source: https://www.mindstick.com/forum/1564/use-openfiledialog-to-get-path-of-open-database-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
