read xml file from application folder

  • Thread starter Thread starter Murtuza
  • Start date Start date
M

Murtuza

Hi I am new to .net compact framework, I am writing an application and would
like to store a xml file in my application directory and read it I tried to
get the application path with
Assembly.GetExecutingAssembly().GetName().CodeBase.ToString();

and list all files under this directory but it only show one .dll file.

Can someone please point me in doing the same.

Thanx
 
How about showing us the code you have that's failing? It's tough to say
what's wrong with something we can't see.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
 
Here the code I have added the test.xml file directly under the project folder

string path =
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;

string xmlFileUrl = new System.IO.FileInfo(path).DirectoryName +
@"\test.xml";

try
{
FileStream strm = new FileStream(xmlFileUrl, FileMode.Open);
}
catch(Exception ex)
{
Console.WriteLine(e.Message);
}
 
You should be using Path.Combine to merge path strings, but aside from that
what's happening? Do you get an exception? If so, have you verified the
test.xml file is actually on the device and in the same folder as the app?
How have you verified this? How about helping us help you and giving us
full information right from the start rather than having us play 20
questions.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
 
sorry just my first week working with windows mobile, I created a new
application and added new xml file using Add new Item by right clicking on
the project name and did the deployment. Just I browsed the file system on my
device and under the project directory I see only .exe file and nothing else.
so my question now would be how to deploy .xml file on the device that we
want to read in the application.
 
Set the file Build Action to "Content" and set "Copy to Output Directory" to
"Copy Always" or "Copy if Newer"


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com
 
Thnax that work, now I can see the .xml file in my app folder. Also I was
wondering if there is a way to hide the .xml file from user and still use it
in the application. I saw example of adding image file to .resx file and
reading it but i am not able to figure out how to read a .xml file.
 
Back
Top