CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2011
    Posts
    2

    Angry C# Application with XML file

    Hi, Ive done a simple application on vs2010 which reads and writes to an xml file that i have in my bin folder but when I deploy the application and run it I get an error that it cant find the xml file, does anyone know why this is and how to solve it, cheers

  2. #2
    Join Date
    May 2011
    Location
    Washington State
    Posts
    220

    Re: C# Application with XML file

    Yeah... depending on how you deploy your application, your XML file is not being created for you in the folder your application is deployed to.

    Either create/copy the XML file to whatever folder your application runs in, or create an application setting to hold a path to where the file is always located and use that when accessing the file in your application.

    Best of luck!

  3. #3
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: C# Application with XML file

    If the plan is to have the xml file in the same folder as the application exe, then the solution is pretty simple.

    All you need to do is add the xml file to the project (if it isn't already part of the project). Just right click on the project in the solution explorer and choose "Add\Existing item...". Add the xml file.

    Next, right click on the xml file in the solution explorer and choose "Properties".

    Under "Copy to Output Directory", change the setting to "Copy always".

    Now when you build the project, the xml file will automatically get copied to the debug or release folder.

  4. #4
    Join Date
    Sep 2011
    Posts
    2

    Re: C# Application with XML file

    thanks guys, I ended up writing a bit of code that when the application loaded up it would read the xml but if it couldnt find an xml file it would create 1, obviously this only happens once when the application is first started, there after it can read it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured