我爱Aspx >> Asp.Net >> 一个文件上传的类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();
Ҷƪл˵?
继承System.Web.UI.Page的页面基..[05-20]
静态方法和静态构造方法[05-20]
高效的Esmtp,带验证,用Socket编..[05-20]
用C#与XML创建动态分层菜单[05-20]
透明FLASH[05-20]
JS类:实现对联式广告[05-20]
网页间非常规方法传递值的方法[05-20]
利用WebClient和WebRequest类获得..[05-20]
通过ASP.NET远程杀死进程[05-20]
Asp.net中DataGrid控件的自定义分..[05-20]