C#生成單頁(yè)靜態(tài)頁(yè)簡(jiǎn)單實(shí)例
更新時(shí)間:2014年10月10日 09:36:04 投稿:shichen2014
這篇文章主要介紹了C#生成單頁(yè)靜態(tài)頁(yè)簡(jiǎn)單實(shí)例,是一個(gè)非常實(shí)用的技巧,需要的朋友可以參考下
本文實(shí)例講述了C#生成單頁(yè)靜態(tài)頁(yè)簡(jiǎn)單實(shí)現(xiàn)方法。分享給大家供大家參考。具體方法如下:
復(fù)制代碼 代碼如下:
protected void BtGroup_ServerClick(object sender, EventArgs e)
{
//產(chǎn)業(yè)群首頁(yè)
string tempGroupData = GetHttpData(" using (StreamWriter sw = new StreamWriter(this.Request.PhysicalApplicationPath + "Group\\Index.html", false, System.Text.Encoding.GetEncoding("utf-8")))
{
sw.Write(tempGroupData);
sw.Flush();
}
}
public string GetHttpData(string sUrl)
{
string sRslt = null;
WebResponse oWebRps = null;
WebRequest oWebRqst = WebRequest.Create(sUrl);
oWebRqst.Timeout = 50000;
try
{
oWebRps = oWebRqst.GetResponse();
}
finally
{
if (oWebRps != null)
{
StreamReader oStreamRd = new StreamReader(oWebRps.GetResponseStream(), System.Text.Encoding.GetEncoding("utf-8"));
sRslt = oStreamRd.ReadToEnd();
oStreamRd.Close();
oWebRps.Close();
}
}
return sRslt;
}
{
//產(chǎn)業(yè)群首頁(yè)
string tempGroupData = GetHttpData(" using (StreamWriter sw = new StreamWriter(this.Request.PhysicalApplicationPath + "Group\\Index.html", false, System.Text.Encoding.GetEncoding("utf-8")))
{
sw.Write(tempGroupData);
sw.Flush();
}
}
public string GetHttpData(string sUrl)
{
string sRslt = null;
WebResponse oWebRps = null;
WebRequest oWebRqst = WebRequest.Create(sUrl);
oWebRqst.Timeout = 50000;
try
{
oWebRps = oWebRqst.GetResponse();
}
finally
{
if (oWebRps != null)
{
StreamReader oStreamRd = new StreamReader(oWebRps.GetResponseStream(), System.Text.Encoding.GetEncoding("utf-8"));
sRslt = oStreamRd.ReadToEnd();
oStreamRd.Close();
oWebRps.Close();
}
}
return sRslt;
}
希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。
相關(guān)文章
C#實(shí)現(xiàn)窗體中動(dòng)態(tài)按鈕的設(shè)計(jì)方法
在窗體界面中,通常以按鈕來(lái)代替菜單欄的功能,這種形式雖然給用戶一種直觀、界面風(fēng)格各異的感覺,但通常按鈕都是以靜止的形式顯示,所以本文給大家介紹了C#實(shí)現(xiàn)窗體中動(dòng)態(tài)按鈕的設(shè)計(jì)方法,感興趣的朋友可以參考下2024-04-04
C# JSON格式化轉(zhuǎn)換輔助類 ConvertJson
本文介紹使用C#原生代碼實(shí)現(xiàn) JSON格式化以及各種類型轉(zhuǎn)化JSON的輔助類,幫助開發(fā)人員快速開發(fā)。2016-04-04
Unity3D應(yīng)用之時(shí)鐘與鐘表小組件的使用教程
這篇文章主要來(lái)和大家詳細(xì)介紹一下Unity3D應(yīng)用開發(fā)中的時(shí)鐘和鐘表小組件的使用,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2023-01-01
C#控件picturebox實(shí)現(xiàn)畫圖功能
這篇文章主要為大家詳細(xì)介紹了C#控件picturebox實(shí)現(xiàn)畫圖功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-09-09
C#使用ICSharpCode.SharpZipLib.dll進(jìn)行文件的壓縮與解壓功能
這篇文章主要介紹了C#使用ICSharpCode.SharpZipLib.dll進(jìn)行文件的壓縮與解壓功能,需要的朋友可以參考下2017-12-12

