0

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.

2 Answers 2

1

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 e.g. in a config file like App.Config.

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

Comments

-1

Try this:

Dim FullFilePath As String  
Dim FileName As String  

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

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.