Hello,
This is using the Compact Framework 2.0, so cannot use the currentDirectory or startupPath, I have used the code below. However, the path i get is \programFile\PDACodeRedWM5 which is returned
PDACodeRedWM5 being the name of my project.
However, this path doesn't exist on my file system. So i got an error saying 'Could not find a part of the path '\C:\Program Files\PDACodeRedWM5\webServiceUrl.xml'.
So i created this actual path on my file system and still got the same error message.
This is my code so you can have a better understanding, I am trying to read in a xml file into a Dataset.
Try
'File the xml file
Dim fileName As String = String.Empty
Dim ds As New DataSet
Dim dv As DataView
Dim path As String
path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetModules(0).FullyQualifiedName)
'Read in the xml file
fileName = String.Format("{0}\WebServiceURL.xml", path)
ds.ReadXml(fileName)
'Find if a url already exists
dv = New DataView(ds.Tables(0))
If (dv.Count = 0) Then
'This is the first time the application is running, so input from user
Dim objInputURL As New InputURL()
objInputURL.ShowDialog()
Else 'Set the URL to the current web service location
Dim objUrl As New Globals
objUrl.UrlPath = ds.Tables(0).Rows(0)("url").ToString()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
If the programFile\PDACodeRedWM5 has not been created why does it give that file path?
The actual path the application is in, is on my D drive.
Many thanks for any help,
Steve