0

I can load my XML file as expected during debugging mode using the code as follows:

Dim strm As New FileStream(System.IO.Path.GetFullPath(Application.StartupPath & "\QuestionList.xml"), FileMode.Open)

But after I published my project using ClickOnce Deployment, an error message is always prompting stating that:

Could not find the file: 'C:\Documents and Settings*username*\Local Settings\Apps\2.0\RANDOM CHARACTERS HERE\QuestionList.xml'

A File not found exception occurs.

My problem is similar with this question here in SO, and tried the solutions proposed out there but with no luck, just like the original poster.

Why can't I access an XML file onced I published my project?

Community
  • 1
  • 1
Arman
  • 1,434
  • 2
  • 22
  • 42
  • Removed C# tag. Let me know if this is a mistake. – tnw Nov 01 '13 at 20:12
  • Do you have the file in place? – Sriram Sakthivel Nov 01 '13 at 20:14
  • @SriramSakthivel Yes, in my Application folder, but does not appear in 'C:\Documents and Settings*username*\Local Settings\Apps\2.0\RANDOM CHARACTERS HERE\QuestionList.xml' – Arman Nov 01 '13 at 20:15
  • What is your application folder? When you deploy it as clickonce application your application folder will be in somewhat like Temp folder only – Sriram Sakthivel Nov 01 '13 at 20:20
  • @SriramSakthivel Sorry I mean it is placed just as where my forms and other resources are. That's why I am calling `Application.StartupPath & "\QuestionList.xml"`. Should I place it somewhere else? – Arman Nov 01 '13 at 20:26
  • Why not add the xml in your click once project and copy the file in ApplicationPath ? – Sriram Sakthivel Nov 01 '13 at 20:27
  • @SriramSakthivel Hmm what do you mean by my "click once project"? Is it in the bin or debug folder. Sorry, I'm new in this one. – Arman Nov 01 '13 at 20:32
  • http://stackoverflow.com/questions/940025/adding-files-to-a-click-once-deployment this could help – Sriram Sakthivel Nov 01 '13 at 20:35
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/40402/discussion-between-arman-and-sriram-sakthivel) – Arman Nov 01 '13 at 20:48

2 Answers2

2

Clickonce applications once deployed will be in AppData\XYZ...BlahBlahBlah. You get an error because your xml doesn't exist there. That is the path where you need your QuestionList.xml to make it work.

So basically you need to deploy your xml when you deploy your binaries, Follow the instructions given here, It will guide you how to copy files to clickonce installation path.

Community
  • 1
  • 1
Sriram Sakthivel
  • 72,067
  • 7
  • 111
  • 189
0

try using double slash:

"\\QuestionList.xml"
Rafa
  • 443
  • 5
  • 14
  • hmm also (in C#..) I would try something like) string x = Application.StartupPath & "\QuestionList.xml"; and use @x as parameter – Rafa Nov 01 '13 at 20:24