熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

.NET Framework中的Uploadfile代碼

2013-11-13 10:32:13  來源: .NET編程 

  在頁面部分加入 office:office />

  在代碼部分加

  void btnUploadTheFile_Click(object sender SystemEventArgs e)

  {

  if (uplTheFilePostedFile != null)

  {

  HttpPostedFile mFile= uplTheFilePostedFile;

  int fileSize = mFileContentLength;

  if (fileSize==)

  {

  txtErrMsgInnerText = No file uploaded try again;

  return;

  }

  try

  {

  byte[] mFileByte = new Byte[fileSize];

  mFileInputStreamRead(mFileBytefileSize);

  string sFilename = ClientID + SystemIOPathGetFileName(mFileFileName);

  SystemIOFileStream saveFile = new SystemIOFileStream(ServerMapPath(~/+RequestQueryString[UploadPath]+ / + sFilename) SystemIOFileModeCreate);

  saveFileWrite(mFileByte mFileByteLength);

  saveFileClose();

  }

  catch

  {

  txtErrMsgInnerText = File uploaded Unsuccessfull try again;

  }

  }

  }


From:http://tw.wingwit.com/Article/program/net/201311/13933.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.