嗨,任何人都可以解决这个问题. [英] hi can any one solve this..

查看:78
本文介绍了嗨,任何人都可以解决这个问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在将文件上传到asp.net中的目标文件夹时出现错误.这是我的代码..

hi m getting error while uploading file to target folder in asp.net.. here is my code..

public string uploadFile(string fileName, string folderName)
  {

      if (fileName == "")
      {

          return "Invalid filename supplied";

      }

      if (fileUpload.PostedFile.ContentLength == 0)
      {

          return "Invalid file content";

      }

      fileName = System.IO.Path.GetFileName(fileName);

      if (folderName == "")
      {

          return "Path not found";

      }

      try
      {

          if (fileUpload.PostedFile.ContentLength <= 2048000)
          {

              fileUpload.PostedFile.SaveAs(Server.MapPath(folderName) + "\\" + fileName);

              return "File uploaded successfully";

          }

          else
          {

              return "Unable to upload,file exceeds maximum limit";

          }

      }

      catch (UnauthorizedAccessException ex)
      {

          return ex.Message + "Permission to upload file denied";

      }

  }




这是我的btnSave代码.




and here is my btnSave code.

protected void btnSave_Click(object sender, EventArgs e)
    {
        string strFilename, strMessage;

        strFilename = fileUpload.PostedFile.FileName.ToString();

        strMessage = uploadFile(strFilename, ConfigurationSettings.AppSettings["folderPath"]);

        lblMessage.Text = strMessage;

        //lblMessage.ForeColor = Color.Red;
    }




错误是




error is

fileUpload.PostedFile.SaveAs(Server.MapPath(folderName) + "\\" + fileName);





Could not find a part of the path ''C:\Users\admin\Documents\Visual Studio 2008\WebSites\pmsw(new)\Admin\10.3.2\Concrete_Basement_Wall.xls''. 



我创建了一个文件夹,名为10.3.2.so,我想将该文件上传到此文件夹..任何人都可以解决吗?



and i created one folder as 10.3.2.so i want to upload that file into this folder..can any one solve??

推荐答案



文件夹名称参数的值是多少.它必须是相对路径值....

此处查看 [此处 [
Hi,

Whats value you have for folder name parameter. It must be relative path value....

Check here[^] and here[^].


这篇关于嗨,任何人都可以解决这个问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆