HI Guys,
I have completed my VB project using vb 2008 express edition..
I am not able to create a set up file for my project and I think it is because of the file path i have provided in my program
dbSource = "Data Source = C:\Documents and Settings\cfadmin\Desktop\Lead_management\Lead_Management_Project\Lead_Management_Project\London.mdb"

The above path is a fixed path which connects my program to the database. Now when I create a set up file and try to run on another machine it wont recognize this path .
I have placed the database in the same folder that of the program.

Could anyone please help me how can I give a relative path or any other solution...


To get the path toapplication you can try on of these:

Dim Path1 As String = Application.StartupPath

Dim exe As System.Reflection.Assembly = System.Reflection.Assembly.GetEntryAssembly()
Dim Path2 As String = System.IO.Path.GetDirectoryName(exe.Location)

Dim Path3 As String = Path.GetDirectoryName(Application.ExecutablePath)

Dim path4 As String = Path.GetDirectoryName(Assembly.GetAssembly(GetType(Form1)).CodeBase)

Dim strAppDir As [String] = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase)
Dim strFullPathToMyFile As [String] = Path.Combine(strAppDir, "fileName.txt")

Dim root As String = New FileInfo(Assembly.GetExecutingAssembly().Location).FullName
Dim fullAppName As [String] = Assembly.GetExecutingAssembly().GetName().CodeBase
Dim fullAppPath As [String] = Path.GetDirectoryName(fullAppName)
Dim fullFileName As [String] = Path.Combine(fullAppPath, "myfile.txt")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.