首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

.Net写文件的有关问题(急)

2012-01-13 
.Net写文件的问题(急)~/App_Code/FlashAd.cs内容publicvoidCreateFlashADJS(DataTabledt){System.IO.Strea

.Net写文件的问题(急)
~/App_Code/FlashAd.cs   内容
    public   void   CreateFlashADJS(DataTable   dt)
        {
                        System.IO.StreamWriter   mystr;
                        string   Pics   =   "var   pics= ' ";
                        string   Links   =   "var   links= ' ";
                        string   Texts   =   "var   texts= ' ";
                        string   FlashADJS   =   "var   focus_width=230; ";
                        FlashADJS   +=   "var   focus_height=200; ";
                        FlashADJS   +=   "var   text_height=0; ";
                        FlashADJS   +=   "var   swf_height   =   focus_height+text_height; ";
                        for   (int   i   =   0;   i   <   dt.Rows.Count;   i++)
                                              {
                                                        Pics   +=   dt.Rows[i][ "PicUrl "].ToString();
                                                        Links   +=   dt.Rows[i][ "Url "].ToString();
                                                        Texts   +=   dt.Rows[i][ "Title "].ToString();
                                                        if   (i   <   dt.Rows.Count   -   1)
                                                        {
                                                                Pics   +=   "| ";
                                                                Links   +=   "| ";
                                                                Texts   +=   "| ";


                                                        }
                                                }
                                                Pics   +=   " '; ";
                                                Links   +=   " '; ";
                                                Texts   +=   " '; ";
                                                FlashADJS   =   FlashADJS   +   Pics   +   Links   +   Texts;
                                                    mystr=File.CreateText(page.Server.MapPath( "FlashAd/adlibrary.js "));
                                                    mystr.Write(FlashADJS);
                                                    mystr.Close();
                                                    mystr   =   null;
}

~/Admin/FlashAd/adlibrary.js   就是要写这个文件

[解决办法]
System.IO.StreamWriter sw = new System.IO.StreamWriter(page.Server.MapPath( "FlashAd/adlibrary.js "));
sw.Write(FlashADJS);
sw.Flush();
sw.Close();
[解决办法]
bd
[解决办法]
帮你顶吧。。
StreamWriter s = new StreamWriter(Server.MapPath( "/Admin/FlashAd/adlibrary.js "));

s.Write(FlashADJS);
s.Close();
[解决办法]
权限够吗?
[解决办法]
string fname = Server.MapPath( "../Temp ") + "\\ " +stime;
FileInfo finfo = new FileInfo(fname);
using(FileStream fs = finfo.OpenWrite())
{
StreamWriter sw = new StreamWriter(fs,System.Text.Encoding.GetEncoding( "GB2312 "));
sw.WriteLine(strhtml);
sw.Flush();
sw.Close();
}

热点排行