日本好好热aⅴ|国产99视频精品免费观看|日本成人aV在线|久热香蕉国产在线

  • <cite id="ikgdy"><table id="ikgdy"></table></cite>
    1. 西西軟件園多重安全檢測(cè)下載網(wǎng)站、值得信賴的軟件下載站!
      軟件
      軟件
      文章
      搜索

      首頁編程開發(fā)C#.NET → C#創(chuàng)建文件夾代碼

      C#創(chuàng)建文件夾代碼

      相關(guān)軟件相關(guān)文章發(fā)表評(píng)論 來源:本站整理時(shí)間:2010/11/23 9:32:58字體大。A-A+

      作者:佚名點(diǎn)擊:1130次評(píng)論:0次標(biāo)簽: 文件夾

      • 類型:文件處理大。1.6M語言:中文 評(píng)分:5.0
      • 標(biāo)簽:
      立即下載

      ///<summary>
         
      ///創(chuàng)建文件夾

           ///</summary>
          publicclass Util
          {
              [DllImport(
      "msvcrt.dll", SetLastError =true, CharSet = CharSet.Unicode, ExactSpelling =true)]
             
      privatestaticexternint _mkdir(string path);

             
      ///<summary>
             
      /// 創(chuàng)建目錄
             
      ///</summary>
             
      ///<param name="path"></param>
             
      ///<returns></returns>
              publicstatic DirectoryInfo CreateDirectory(string path)
              {
                  DirectoryInfo oDir
      =new DirectoryInfo(Path.GetFullPath(path));

                 
      try
                  {
                     
      if (!oDir.Exists)
                      {
                          oDir.Create();
                      }
                     
      return oDir;
                  }
                 
      catch
                  {
                      CreateDirectoryUsingDll(oDir);
                     
      returnnew DirectoryInfo(path);
                  }
              }

             
      privatestaticvoid CreateDirectoryUsingDll(DirectoryInfo dir)
              {
                  ArrayList oDirsToCreate
      =new ArrayList();

                 
      while (dir !=null&&!dir.Exists)
                  {
                      oDirsToCreate.Add(dir.FullName);
                      dir
      = dir.Parent;
                  }

                 
      if (dir ==null)
                  {
                     
      throw (new System.IO.DirectoryNotFoundException("Directory \"" + oDirsToCreate[oDirsToCreate.Count - 1] + "\" not found."));
                  }

                 
      for (int i = oDirsToCreate.Count -1; i >=0; i--)
                  {
                     
      string sPath = (string)oDirsToCreate[i];
                     
      int iReturn = _mkdir(sPath);

                     
      if (iReturn !=0)
                      {
      #if DEBUG
                         
      thrownew ApplicationException("Error calling [msvcrt.dll]:_wmkdir("+ sPath +"), error code: "+ iReturn);
      #else
                         
      thrownew ApplicationException();
      #endif
                      }
                  }
              }
          }

        相關(guān)評(píng)論

        閱讀本文后您有什么感想? 已有人給出評(píng)價(jià)!

        • 8 喜歡喜歡
        • 3 頂
        • 1 難過難過
        • 5 囧
        • 3 圍觀圍觀
        • 2 無聊無聊

        熱門評(píng)論

        最新評(píng)論

        發(fā)表評(píng)論 查看所有評(píng)論(0)

        昵稱:
        表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
        字?jǐn)?shù): 0/500 (您的評(píng)論需要經(jīng)過審核才能顯示)