码迷,mamicode.com
首页 > Windows程序 > 详细

C# 文件上传简单示例

时间:2015-04-12 09:07:52      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

Default.aspx

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>文件上传测试</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:FileUpload ID="FileUpload1" runat="server" />
        <asp:Button ID="BtnUpload" runat="server" Text="上传" OnClick="BtnUpload_Click" />
    </div>
    </form>
</body>
</html>

Default.aspx.cs

  protected void BtnUpload_Click(object sender, EventArgs e)
        {
            string path = "c:\\pdfword\\";
            if (FileUpload1.HasFile)
            {
                try
                {
                    FileUpload1.SaveAs(path + FileUpload1.FileName);
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message);
                }
            }
        }

 

C# 文件上传简单示例

标签:

原文地址:http://www.cnblogs.com/aoun/p/4419019.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!