我想在网站目录下建一个文件夹,具体来说就是通过后台类在webRoot下建一个文件夹,用于存储文件,在程序中如何实现。是不是用到相对路径问题。

解决方案 »

  1.   

    Directory.Create(Server.MapPath("../YourFolderName")); //bin的上级目录下创建。
      

  2.   

    string savePath = Server.MapPath("~/upload/");  
    if (!System.IO.Directory.Exists(savePath)) 
                { 
                    System.IO.Directory.CreateDirectory(savePath); 
                } 
      

  3.   

    弱弱的问一下,你发布的WebSite,Bin在哪一级目录下?
      

  4.   

    如果你用的是sturts 那么项目路径就是request.getSession().getContext().getRealPath("/");
      

  5.   

    当然我指的是用ssh集成的时候。
      

  6.   

    在网站下的任何一个网页,打入以下代码,就会在跟目录下创建一个文件夹:
      string sPath = Server.MapPath("~/你的文件夹名/");   
      if (!System.IO.Directory.Exists(sPath))  
      {  
           System.IO.Directory.CreateDirectory(sPath);  
      }  
      

  7.   

    怎么查不到?msdn上http://msdn.microsoft.com/zh-cn/library/54a0at6s.aspx
      

  8.   

    所有的文件、文件夹操作都在这下面
    http://msdn.microsoft.com/zh-cn/library/system.io.aspx
      

  9.   

    IO 操作
    http://msdn.microsoft.com/zh-cn/library/system.io.directory(VS.80).aspx
      

  10.   

    string savePath = Server.MapPath("~/");   
    if (!System.IO.Directory.Exists(savePath))  
      {  
      System.IO.Directory.CreateDirectory(savePath);  
      }