Start New Discussion within our Software Development Community

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...


Regards,
Ashwin

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")
This article has been dead for over six months. Start a new discussion instead.