• λ我爱Aspx >> Asp.Net >> 一个文件上传的类
  • 一个文件上传的类

  • :未知  Դ:internet  :2007-5-20 16:44:41  ؼ:
  • return path.Substring(pos+1);

    }

    public string Upload()

    {

    if(PostedFile!=null)

    {

    try{

    string fileName=PathToName(PostedFile.FileName);

    if(!fileName.EndsWith(Extension)) return "You must select "+Extension+" file!";

    if(PostedFile.ContentLength>FileLength) return "File too big!";

    PostedFile.SaveAs(SavePath+fileName);

    return "Upload File Successfully!";

    }

    catch(System.Exception exc)

    {return exc.Message;}

    }

    return "Please select a file to upload!";

    }

    }

    }

    用csc /target:Library Wmj.cs 编译成dll供以后多次调用

    调用举例

    <%@page language="C#" runat="server"%>

    <%@import namespace="Wmj"%>

    <script language="C#" runat="server">

    void Upload(object sender,EventArgs e)

    {

    MyUpload myUpload=new MyUpload();

    Ҷƪл˵?
  • һƪASP.NET中使用Caching
    һƪ继承System.Web.UI.Page的页面基类