page:
<td width="320"> <!------------------------------------------------------------------------------------------------------> <object id="scriptmain" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/ flash/swflash.cab#version=6,0,29,0" height="220" name="scriptmain" width="320"> <param name="movie" value="bcastr.swf?bcastr_xml_url=EventNews.xml"> <param name="quality" value="high"> <param name="scale" value="noscale"> <param name="LOOP" value="false"> <param name="wmode" value="transparent"> <embed height="261" loop="False" menu="false" name="scriptmain" pluginspage="http://www.macromedia.com/go/getflashplayer" quality="high" salign="T" src="bcastr.swf?bcastr_xml_url=EventNews.xml" type="application/x-shockwave-flash" width="286" wmode="transparent"></embed> </object>
</td>
CS:
protected void Page_Load(object sender, EventArgs e) {
this.InitPicture();
}
private void InitPicture() { try { string sSQL = "select top 1 photo from News where type='3' and IsUse='Y' and Isopen='Y' order by Sign_date desc"; DataSet ds = new DataSet(); ds = MySqlBase.GetVarsAsDataSet(sSQL); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { #region DataSet dsAd = new DataSet(); dsAd = MySqlBase.GetVarsAsDataSet(sSQL); //*************************************88 string sText = ""; StreamWriter sw = null; if (dsAd.Tables[0].Rows.Count > 0) { if (File.Exists(Server.MapPath("./") + "EventNews.xml")) { File.Delete(Server.MapPath("./") + "EventNews.xml"); }
sText += "<?xml version='1.0' encoding='utf-8' ?> /r/n"; sText.Replace("'", "''"); sText += "<bcaster autoPlayTime=/"5/">/r/n"; for (int i = 0; i < dsAd.Tables[0].Rows.Count; i++) { string photos = dsAd.Tables[0].Rows[i]["photos"].ToString(); string[] str = photos.Split('|'); for (int j = 0; j < str.Length - 1; j++) { sText += "<item item_url=/"" + LaurelPhotoUrl + "/" + str[j] + "/" >"; sText += "</item>/r/n"; } } sText += "</bcaster>"; } else { if (File.Exists(Server.MapPath("./") + "EventNews.xml")) { File.Delete(Server.MapPath("./") + "EventNews.xml"); } }
// 自動生成文件和寫入文件 if (File.Exists(Server.MapPath("./") + "EventNews.xml")) { File.Delete(Server.MapPath("./") + "EventNews.xml"); }
sw = File.CreateText(Server.MapPath("./") + "EventNews.xml"); sw.Write(sText);
if (sw != null) { sw.Close(); } #endregion } else//刪除原來的xml { if (File.Exists(Server.MapPath("./") + "EventNews.xml")) { File.Delete(Server.MapPath("./") + "EventNews.xml"); } } } } catch (Exception error) { string x = error.Message; } }