views:

12

answers:

1

Hi,

I have created a windows application, which gets a xml file from the URL and save it on my local machine.In this application a Timer control is set for get the updated XML file from the URL and show the update into label. I have created a setup project and Installed it on another system.

Problem is that, The installed application is get the updated XML but the update is not show into label. But the same application is running on my system from the Visual Studio it works fine.

Please help I am unable to find out what is the problem.

A: 

Sample code is following:

    public void GetResponse()
    {
        try
        {
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("URL of XML file");
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            StreamReader input = new StreamReader(response.GetResponseStream());
            DataSet dsTest = new DataSet();
            dsTest.ReadXml(input);
            DataRow dr;
            dtShow = dsTest.Tables[0].Clone();
            int iRowCount, iBackupRow;
            iRowCount = dsTest.Tables[0].Rows.Count;

            if (File.Exists(path + "/xml/backup.xml"))
            {
                dsBackUp = new DataSet();
                dsBackUp.ReadXml(path + "/xml/backup.xml");
                //MessageBox.Show(dsBackUp.Tables[0].Rows.Count.ToString());
            }
            else
            {
                Directory.CreateDirectory(path + "/xml");
            }
            if (dsBackUp.Tables.Count > 0)
            {
                iBackupRow = dsBackUp.Tables[0].Rows.Count;
            }
            else
            {
                iBackupRow = 0;
            }
            int iFlag = 0;
            if (iBackupRow > 0)
            {
                for (int iLoop = 0; iLoop < iRowCount; iLoop++)
                {
                    for (int jLoop = 0; jLoop < iBackupRow; jLoop++)
                    {
                        if (Convert.ToString(dsTest.Tables[0].Rows[iLoop]["text"]) == Convert.ToString(dsBackUp.Tables[0].Rows[jLoop]["text"]))
                        {
                            iFlag = 1;
                            break;
                        }
                        else
                        {
                            iFlag = 0;
                        }
                    }
                    if (iFlag == 0)
                    {
                        dr = dtShow.NewRow();
                        dr["Id"] = dsTest.Tables[0].Rows[iLoop]["Id"].ToString().Trim();
                        dr["photo"] = dsTest.Tables[0].Rows[iLoop]["photo"].ToString().Trim();
                        dr["text"] = dsTest.Tables[0].Rows[iLoop]["text"].ToString().Trim();
                        dr["link"] = dsTest.Tables[0].Rows[iLoop]["link"].ToString().Trim();
                        dr["modifiedDate"] = dsTest.Tables[0].Rows[iLoop]["modifiedDate"].ToString().Trim();
                        dtShow.Rows.Add(dr);
                    }
                }
                if (dtShow.Rows.Count > 0)
                {
                    timer1.Start();
                    timer1.Enabled = true;
                }
                else
                {
                    timer1.Stop();
                    timer1.Enabled = false;

                    timer2.Start();
                    timer2.Enabled = true;

                }
                dsBackUp = new DataSet();
                dsBackUp = dsTest;
                if (File.Exists(path + "/xml/backup.xml"))
                {
                    File.Delete(path + "/xml/backup.xml");
                }
                dsBackUp.WriteXml(path + "/xml/backup.xml");
            }
            else
            {
                dsBackUp = dsTest;
                dtShow = dsTest.Tables[0];
                if (File.Exists(path + "/xml/backup.xml"))
                {
                    File.Delete(path + "/xml/backup.xml");
                }
                dsBackUp.WriteXml(path + "/xml/backup.xml");
                timer1.Start();
                timer1.Enabled = true;
            }



            int iShowRowCount = dtShow.Rows.Count;
            if (iShowRowCount > 0)
            {
                Point point = new Point();
                int iLoop;
                for (iLoop = 0; iLoop < iShowRowCount; iLoop++)
                {
                    PictureBox img = new PictureBox();
                    img.Width = 64;
                    img.Height = 42;
                    point.X = 6;
                    point.Y = iLoop * 54 + 6;
                    img.Location = point;
                    img.ImageLocation = dtShow.Rows[iLoop]["photo"].ToString();
                    img.Cursor = Cursors.Hand;

                    Label lbl = new Label();
                    lbl.Width = 180;
                    lbl.Height = 42;
                    point.X = 86;
                    point.Y = iLoop * 54 + 6;
                    lbl.Location = point;
                    lbl.Text = dtShow.Rows[iLoop]["text"].ToString();
                    lbl.Cursor = Cursors.Hand;

                    Label lblLine = new Label();
                    point.X = 0;
                    point.Y = iLoop * 54;
                    lblLine.Location = point;
                    lblLine.Height = 1;
                    lblLine.Width = 236;
                    lblLine.BackColor = Color.NavajoWhite;
                    lblLine.Name = "lbl_" + iLoop.ToString();
                    lblLine.Text = ".";

                    panNews.Controls.Add(img);
                    panNews.Controls.Add(lbl);
                    panNews.Controls.Add(lblLine);

                    panNews.Height = 54 * iShowRowCount;

                    lbl.Name = "lbl_" + iLoop.ToString();
                    img.Name = "img_" + iLoop.ToString();
                    lbl.Click += new EventHandler(lbl_Click);
                    img.Click += new EventHandler(img_Click);

                }
                Label lLine = new Label();
                point.X = 0;
                point.Y = (iLoop * 54) - 1;
                lLine.Location = point;
                lLine.Height = 1;
                lLine.Width = 236;
                lLine.BackColor = Color.NavajoWhite;
                lLine.Name = "lbl_" + iLoop.ToString();
                lLine.Text = ".";

                panNews.Controls.Add(lLine);

                Point p = new Point();
                p.Y = panNews.Location.Y + iShowRowCount * 54;
                p.X = 0;
                pictureBox2.Location = p;
                this.Location = new Point(X - pictureBox1.Width, Y - (pictureBox1.Height + panNews.Height + pictureBox2.Height)); // This line sets the initial location of the form
                this.Height = pictureBox1.Height + panNews.Height + pictureBox2.Height;
            }
            else
            {
                HidePage();
            }
        }
        catch (Exception Except)
        {
            MessageBox.Show(Except.Message);
            HidePage();
        }

    }

I hope this will help someone

cmant
I got the solution: "panNews" is the Panel control and its was not clear before adding new news. Thanks for viewing
cmant