I am writing an application in VB2008 Express Edition and I have included a button on the main menu of my application to allow the user to create a backup of the database (single user instance application). When debugging I have the following code for the button which works perfectly:
Me.Cursor = Cursors.WaitCursor
Dim path1 As String = "C:\ECP1\ECP1\Bin\Debug\Resources\EolasBase.mdf"
Dim constring As String = My.Settings.EolasBaseConnectionString
Dim con As SqlConnection = New SqlConnection(constring)
Dim cmdstring As String = "backup database [" + path1 + "] to disk = 'C:\ECP1\backup.bak' with format"
Dim cmd As New SqlCommand(cmdstring, con)
Me.Cursor = Cursors.Default
However, when I change the path of the database (the string 'path1') for deployment purposes
(i.e.Dim path1 As String = my.application.deployment.datadirectory + "\Resources\EolasBase.mdf") and then deploy the application on my laptop, I get the following error:
The identifier that starts with 'C:\Documents and Settings\MichaelC\Local Settings\Apps\2.0\Data\8NEVGHNG.015\2EMOTG3Z.767\ecp1..tion_d347718c1e7df98e_0000.0001_' is too long. Maximum length is 128.
I've been searching for an answer on the internet and haven't gotten anywhere. Obviously the path is much longer than it was when debugging but I need a way around it. It's probably just a problem with syntax somewhere but I would appreciate any direction. Thanks!