我是靠谱客的博主 如意银耳汤,这篇文章主要介绍C#学习之获取某个文件下的目录列表及子目录列表,现在分享给大家,希望可以做个参考。

 

/// <summary>

        /// 获取程序当前文件目录下的所有文件列表
        /// </summary>
        /// <param name="path">文件搜索路径</param>
        /// <returns>文件名列表</returns>
        private List<string> GetAllFiles(string A_Path)
        {
            List<string> l_Files = new List<string>();
            DirectoryInfo l_DirecInfo = new DirectoryInfo(A_Path);
            foreach (FileInfo l_FileInfo in l_DirecInfo.GetFiles("*"))
            {
                l_Files.Add(l_FileInfo.FullName);
            }
            foreach (DirectoryInfo l_DirecInfoChild in l_DirecInfo.GetDirectories("*"))
            {
                GetAllFiles(l_DirecInfoChild.FullName);
            }
            if (l_Files.Count > 0)
            {
                return l_Files;
            }
            else
                return null;
        }

最后

以上就是如意银耳汤最近收集整理的关于C#学习之获取某个文件下的目录列表及子目录列表的全部内容,更多相关C#学习之获取某个文件下内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(47)

评论列表共有 0 条评论

立即
投稿
返回
顶部