在页面部分加入 office:office" />
在代码部分加:
void btnUploadTheFile_Click(object sender, System.EventArgs e)
{
if (uplTheFile.PostedFile != null)
{
HttpPostedFile mFile= uplTheFile.PostedFile;
int fileSize = mFile.ContentLength;
if (fileSize==0)
{
txtErrMsg.InnerText = "No file uploaded, try again";
return;
}
try
{
byte[] mFileByte = new Byte[fileSize];
mFile.InputStream.Read(mFileByte,0,fileSize);
string sFilename = ClientID + System.IO.Path.GetFileName(mFile.FileName);
System.IO.FileStream saveFile = new System.IO.FileStream(Server.MapPath("~/"+Request.QueryString["UploadPath"]+ "/" + sFilename), System.IO.FileMode.Create);
saveFile.Write(mFileByte,0, mFileByte.Length);
saveFile.Close();
}
catch
{
txtErrMsg.InnerText = "File uploaded Unsuccessfull, try again";
}
}
}