帮忙看看这段代码
if (this.fulFile.PostedFile.FileName.Length==0)
{
MessageBox.Show(this,"请选择要上传的公文!");
}
else
{
if (Request.Files[0].ContentType=="application/msword")
{
string fileName = this.fulFile.PostedFile.FileName.ToString();
int index = fileName.LastIndexOf(".");
string name = fileName.Substring(index);
string onLineName = DateTime.Now.Second.ToString() + "_" + this.fulFile.PostedFile.ContentLength + name; //这段代码报错 说是找不到路径
if (fileName.Length!=null)
{
this.fulFile.PostedFile.SaveAs(Server.MapPath("Document/" + onLineName));
}
MessageBox.Show(this, "上传成功!");
}
else
{
MessageBox.Show(this, "上传的文件只能为Word文件!");
}
}
大家帮帮忙 我解决了半天了解决不了 谢了
if (this.fulFile.PostedFile.FileName.Length==0)
{
MessageBox.Show(this,"请选择要上传的公文!");
}
else
{
if (Request.Files[0].ContentType=="application/msword")
{
string fileName = this.fulFile.PostedFile.FileName.ToString();
int index = fileName.LastIndexOf(".");
string name = fileName.Substring(index);
string onLineName = DateTime.Now.Second.ToString() + "_" + this.fulFile.PostedFile.ContentLength + name; //这段代码报错 说是找不到路径
if (fileName.Length!=null)
{
this.fulFile.PostedFile.SaveAs(Server.MapPath("Document/" + onLineName));
}
MessageBox.Show(this, "上传成功!");
}
else
{
MessageBox.Show(this, "上传的文件只能为Word文件!");
}
}
大家帮帮忙 我解决了半天了解决不了 谢了
int index = fileName.LastIndexOf("."); 这个你想取什么? 一个日期 然后定义为图片名么?
string name = fileName.Substring(index);
导致你后面的错了...
取出文件名就可以上传了
string file = fileName.LastIndexOf("\\")+1;
fulFile.PostedFile.SaveAs(Server.MapPath("Document/" + file));
这是报出来的错误