简体   繁体   中英

File Path of Access Database

I'm working with vb.net 2008 as well. But I have a question.How to remove a file path like this C:\\users\\myDocu\\debug\\Dbase.accdb and I only want is the file name Dbase.accdb. Because I want to transfer my files in another computer but the problem is the file path. I always need to change the entire location in my codes to run without debug.

To get the filename without the path, you can use Path.GetFileName .

But if you want a painless way to find a place to store your database, consider putting it into the application data folder ( AppData ). You can get this folder with Environment.GetFolderPath and Environment.SpecialFolder.ApplicationData , using it like this:

Dim pathToDb = Path.Combine(
                    Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), 
                    "Dbase.accdb")

if you want to use the file locally. If you want to share the file between different instances of your application in a network, put the path eg in a config file like App.Config .

Try this:

Dim FullFilePath As String  
Dim FileName As String  

FullFilePath = "C:\users\myDocu\debug\Dbase.accdb"  
FileName = Mid(FullFilePath,InStrRev(FullFilePath,"\") + 1)  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM