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

.NET Framework中的Uploadfile代碼

2022-06-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-2022 電腦知識網 Computer Knowledge   All rights reserved.