设计页面:
<input contentEditable="false" type="file" size="40" name="m_files" id="m_files" />
代码:
protected void Button1_Click(object sender, System.EventArgs e)
{
string m_path = Path.Combine(MapPath("."), "pic");
WebbUpload m_upload = new WebbUpload();
UploadFileCollection m_files = m_upload.GetUploadFileList("m_files");
string m_filePath = string.Empty; foreach (UploadFile m_file in m_files)
{
if (m_file.FileName != null || m_file.FileName != string.Empty)
{
m_filePath = Path.Combine(m_path, Path.GetFileName(m_file.ClientFullPathName));
m_file.SaveAs(m_filePath); this.Label1.Text += "<a href='uploadedFiles\\" + m_file.FileName + "'>uploadedFiles\\" + Path.GetFileName(m_file.ClientFullPathName) + "</a><p>";
}
}
}出错:进入foreach循环时
“m_file.ExtendName”引发了“System.NullReferenceException”类型的异常
<input contentEditable="false" type="file" size="40" name="m_files" id="m_files" />
代码:
protected void Button1_Click(object sender, System.EventArgs e)
{
string m_path = Path.Combine(MapPath("."), "pic");
WebbUpload m_upload = new WebbUpload();
UploadFileCollection m_files = m_upload.GetUploadFileList("m_files");
string m_filePath = string.Empty; foreach (UploadFile m_file in m_files)
{
if (m_file.FileName != null || m_file.FileName != string.Empty)
{
m_filePath = Path.Combine(m_path, Path.GetFileName(m_file.ClientFullPathName));
m_file.SaveAs(m_filePath); this.Label1.Text += "<a href='uploadedFiles\\" + m_file.FileName + "'>uploadedFiles\\" + Path.GetFileName(m_file.ClientFullPathName) + "</a><p>";
}
}
}出错:进入foreach循环时
“m_file.ExtendName”引发了“System.NullReferenceException”类型的异常
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货