Cannot load XML file RRS feed

  • Question

  • Hi All,

    I am trying to load XML file by code but always it is telling file cannot found. I tried to put Config.xml inside Bin and obj folder of my project but it driving same error.

    here is all what i tried.

    1- doc.Load("Config.xml") ' put Config.xml in bin, obj and inside my working project folder but same error.
    Public appPath_live As String = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase
    Dim cmlp As String = appPath_live.Replace("FristProject.exe", "")
        Dim doc = New XmlDocument
        doc.Load( cmlp & "Config.xml")
    dim fullpath as string = "D:/net/FirstProject/"
     Dim doc = New XmlDocument
     doc.Load( fullpath & "Config.xml")

    All thronging same error file cannot found. Please help me where i should put the Config.xml file so easly i can read while my testing and in my mobile device?


    Thank You 


    Tuesday, November 9, 2010 3:27 PM


All replies

  • See this: http://social.msdn.microsoft.com/Forums/en-US/netfxcompact/thread/201b2a92-e9e3-49b9-943f-91bb790815a7/

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, November 9, 2010 4:09 PM

     Dim path As String
        path = System.IO.Path.GetDirectoryName( _
        Dim doc = New XmlDocument
        doc.Load(path & "Config.xml")


    I tried above code but same error.

    Could not find a part of the path '\Program Files\FirstProject\Config.xml'.



    Already i visited that link but i can see they did not solve the issue.

    Anyway if i am trying to run my application direct on Mobile device it is working well. But when i use Microsoft Device Emulator V3 in my desktop the error comes.





    Tuesday, November 9, 2010 4:29 PM
  • In order to open that file it must be at that location. Did you copy that file to that location, either manually or by configuring VS to do it? If you did, then verify if file is indeed at that location using file explorer on device. If not then deployment is not configured properly.
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, November 9, 2010 4:51 PM
  • in VS project explorer i did right click on Config.xml file and select the option Copy to out put Directory : Copy Always.

    is there anyway i can do the manual copy past into Emulator root?


    Thank You

    Tuesday, November 9, 2010 5:15 PM
  • Hi,

    You may find the following useful :-

    Copying Files to the Device/Emulator via VS :-


    Cradling the Emulator :-


    Hope this helps.

    Paul Diston

    Tuesday, November 9, 2010 5:29 PM
  • Paul Diston,


    Great Link working now.

    Thank you

    Tuesday, November 9, 2010 5:52 PM