Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Team,

I have one project which shows XML File data in ASP.NET.

I have published this website online on "http://mytelstraapp.in ". I have multiple customers they submit there data in XML File having fixed name "Form Data.xml"

For First Customer: I have XML File having name "Form Data.xml" For First time when i upload that file online it shows all data correctly.

When For second example, If i upload file as "Form Data.xml" it shows error
Access to the path 'D:\WEBDATA\mytelstraapp.in\Form Data.xml' is denied.

as Form data.xml is already present on server. So Every time I have to Rename that File to get data of second customer .

Please Tell me way so That It Gets Replaced with previous file and will show latest Form Data.xml File data.

I have used this Code

C#
protected void Button1_Click(object sender, EventArgs e)
   {
       if (FileUpload1.HasFile)
       {



           FileUpload1.SaveAs(Server.MapPath("~/") + FileUpload1.FileName);

           Label32.Visible = false;

       }

      if(FileUpload1.HasFile)
      {
       Panel1.Visible = true;
       Panel2.Visible = true;

       FileUpload1.Visible = false;
       Button1.Visible = false;
       XmlReader xmlRdr = XmlReader.Create(Server.MapPath("~/") + FileUpload1.FileName);

       while (xmlRdr.Read())
       {
           if (xmlRdr.Name == "CompanyName")
           {
               Label13.Text = (Label13.Text == string.Empty) ? xmlRdr.ReadString() : Label13.Text;
           }
Posted
Updated 18-Oct-13 5:01am
v3

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