c#

位置:IT落伍者 >> c# >> 浏览文章

.NET Framework中的Uploadfile代码


发布日期:2018年07月19日
 
.NET Framework中的Uploadfile代码

在页面部分加入 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;

}

}

}

               

上一篇:程序员提高C#编程水平的50个要点

下一篇:使用 Visual Basic .NET 访问注册表