Tech Off Thread

4 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

XML and C# on a Windows CE plaform Pocket PC

Back to Forum: Tech Off
  • User profile image
    llan

    Hello, I am trying to convert my C# application to work on a Pocket PC using Windows CE platforms. I have got the Windows WM Developer Resource Kit installed.
    The problem is that it keeps on saying that the XML file is not found. does anyone know what is wrong with the below code.

    [Code]

    public static string doRead()
    {

    reader = new XmlTextReader("users.xml");
    while (reader.Read())
    {
    //This will move to the Next Record
    contents = null;
    reader.MoveToContent();
    //This If statement will only allow the Text within a Tag to be accessed
    if (reader.NodeType == System.Xml.XmlNodeType.Text)
    {

    contents = encryption.Decrypt(reader.Value);
    return contents;

    }


    }
    finish = "True";
    ic = 0;
    reader.Close();
    return contents = null;
    }
    [/Code]

  • User profile image
    cpod

    Unless the path is specified as part of the filename XML Text Reader will assume the file is \users.xml. Try copying the file to the root of the PPC or include a path as part of the filename.

    I know you are using C# but you should be able to get the idea from this bit of VB.NET

     Dim ApplicationPath As String = System.Reflection.Assembly.GetExecutingAssembly().GetModules(0).FullyQualifiedName
    ApplicationPath = System.IO.Path.GetDirectoryName(ApplicationPath)
    If Not ApplicationPath.EndsWith("\") Then ApplicationPath &= "\"
    x = New Xml.XmlTextReader(ApplicationPath & "users.xml")

  • User profile image
    llan

    Thanks, that is what I'm getting the "/users.xml" not "users.xml"

    I have tried using the hint u have provided and i have been able to adapt it to C# like below

    [Code]
    a = System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName;//.GetName().FullName.get.GetModules(0)..ToString();//.GetManifestResourceNames();//..GetModules()...FullyQualifiedName;
                a = System.IO.Path.GetDirectoryName(a);
                //if(a..StartsWith(@"\\"))
        //        {
                if (!a.EndsWith(@"\")) 
                {
                    a += @"\";
                }
                
                XmlTextReader x = new XmlTextReader(a + "users.xml");

    [/Code]

    Now I am getting the path but it is still getting the "/" at the begining. e.g. /Programs/Device/users.xml

    Is there are way of trimming the x variable?

  • User profile image
    llan

    I've fixed the problem.  I am very happy with myself!!!!!!! it was a Option within Visual Studios 8 to Copy File Always or Not etc (for the XML file) and it had Not selected.Mad

    Thanks

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.