2010-10-12 6 views
0

J'ai créé une application Windows qui extrait un fichier XML de l'URL et l'enregistre sur ma machine locale. Dans cette application, un contrôle Timer est défini pour obtenir le fichier XML mis à jour à partir de l'URL et montre la mise à jour dans l'étiquette. J'ai créé un projet d'installation et l'ai installé sur un autre système.XML n'est pas mis à jour dans l'application Windows

Le problème est que, l'application installée obtient le code XML mis à jour mais la mise à jour n'est pas affichée dans l'étiquette. Mais la même application est en cours d'exécution sur mon système à partir du Visual Studio, cela fonctionne très bien.

S'il vous plaît aider Je suis incapable de trouver quel est le problème.

+0

Pouvez-vous poster un échantillon de votre code qui est à l'origine du problème? – kyndigs

Répondre

0

Exemple de code est le suivant:

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(); 
     } 

    } 

J'espère que cela aidera quelqu'un

+0

J'ai obtenu la solution: "panNews" est le contrôle de Panel et il n'était pas clair avant d'ajouter de nouvelles nouvelles. Merci d'avoir consulté – cmant