Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
application works fine in development stage but after publishing the xml cannot load.
the xml file is created in the application.
Please help
the error is:
System.IO.FileNotFoundException: Could not find file 'C:\Users\FADA\AppData\Local\Apps\2.0\6MC9J4BC.P1Z\W8OO308N.5T8\soma..tion_e0ed9ecc8ced09e4_0001.0000_414543578302a54f\somdata.xml'.


What I have tried:

using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace somame
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            string filePath = "somdata.xml";

           dataSet1.ReadXml(filePath);

            dataGridView1.DataSource = dataSet1;
            dataGridView1.DataMember = "mes";
        }
    }
}
Posted
Updated 8-May-21 18:32pm
Comments
Sandeep Mewara 5-Oct-20 10:26am    
What would be helpful here to share how you create/store your xml file.

Look at the error message:
Could not find file 'C:\Users\FADA\AppData\Local\Apps\2.0\6MC9J4BC.P1Z\W8OO308N.5T8\soma..tion_e0ed9ecc8ced09e4_0001.0000_414543578302a54f\somdata.xml'.

It can't be any clearer!

The system has looked in that folder for that file, and can't find it.
Either you have the wrong user, the wrong folder, the wrong file, or your installation process didn't include the data file - but if your app is in a AppData folder then there is something very wrong with your installation!
 
Share this answer
 
Comments
Richard Deeming 5-Oct-20 10:06am    
"... if your app is in a AppData folder then there is something very wrong with your installation!"

Not necessarily. It's quite common for per-user apps to be installed in the user's AppData folder.
Dave Kreskowiak 5-Oct-20 12:34pm    
Or his app was written with certain assumptions in mind that are not correct, which is usually the case with noobs.

In this case, I think the OP is assuming the code knows what he thinks is the "current directory" and it isn't.

Another mistake is only the filename is specified instead of the fully qualified path to the file.
you just need to include the xml file . from right side on the main project name right click and select properties // then publish // then application file
here the xml should be there you just need to make the publish status ( include ) and the download group ( required )
hope it will work as it work with me . :)

p.s you just need to put the xml file in the right side of VS under folder bin/debug is case the xml doesn't show in the application files .
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900