c\#모든 빈 폴 더 를 삭제 하 는 작은 예

803 단어 삭제빈 폴 더

/// <summary>
        ///
        /// “ ”
        /// </summary>
        /// <param name="storagepath"></param>
        public static void KillEmptyDirectory(String storagepath)
        {
            DirectoryInfo dir = new DirectoryInfo(storagepath);
            DirectoryInfo[] subdirs = dir.GetDirectories("*.*", SearchOption.AllDirectories);
            foreach (DirectoryInfo subdir in subdirs)
            {
                FileSystemInfo[] subFiles = subdir.GetFileSystemInfos();
                if (subFiles.Count() == 0)
                {
                    subdir.Delete();
                }
            }
        }

좋은 웹페이지 즐겨찾기