Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application.StartupPath in CF 2.0 not exists

Status
Not open for further replies.

steve1rm

Programmer
Aug 26, 2006
255
GB
Hello,

I am using the Compact Framework 2.0

I have an xml document I would like to read and write to.

I have added the xml doc to my project, but how can I gain access to it when I can't use the application.startup path?

Does anyone have any suggestions?

Many thanks,

Steve
 

Try using System.Enviroment.CurrentDirectory


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
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
 
I have created the path '\program files\PDACodeRedWM5\ and put the xml document inside it. but still get the following "file not found"

Any suggestions will be most helpful.

Steve
 
What kind of device are you writing this for? Are you testing this on your development computer or on the device that is using the program?

-I hate Microsoft!
-Forever and always forward.
 
Hello,

Problem solved. I didn't set the xml file property to "copy if newer" or "always copy"

Thanks,

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top