ASP.NET C# - Save FileStream on server

后端 未结 3 1775
自闭症患者
自闭症患者 2021-01-26 10:46

I got beginners question.

How to save a file stream to a file on server?!

I got this:

var source = Request.QueryString[\"src\"];
WebClient webcli         


        
3条回答
  •  野性不改
    2021-01-26 11:50

    Use Server.MapPath() (also a using block for closing the file would help):

    using(FileStream os = new FileStream(Server.MapPath("/output/asdasdasd.ico"), FileMode.Create))
    {
       var ic = MakeIcon(iconbitmap, 16, false); /// function returns an icon
       ic.Save(os);
    }
    

提交回复
热议问题