在Default.aspx中增加"FileUpload"控件和一个Button控件;
插入以下代码
Code
protected void Button1_Click(object sender, EventArgs e)
{
HttpPostedFile myfile = FileUpload1.PostedFile;
string filename = myfile.FileName.Substring(myfile.FileName.LastIndexOf(@"\") + 1);
if (myfile.ContentLength > 1024000)
{
myfile.SaveAs(@"c:\" + filename);
}
else
{
myfile.SaveAs(@"d:\" + filename);
}
}