getdirectories

List all files and directories in a directory + subdirectories

隐身守侯 提交于 2019-11-28 16:56:01
I want to list every file and directory contained in a directory and subdirectories of that directory. If I chose C:\ as the directory, the program would get every the name of every file and folder on the hard drive that it had access to. A list might look like fd\1.txt fd\2.txt fd\a\ fd\b\ fd\a\1.txt fd\a\2.txt fd\a\a\ fd\a\b\ fd\b\1.txt fd\b\2.txt fd\b\a fd\b\b fd\a\a\1.txt fd\a\a\a\ fd\a\b\1.txt fd\a\b\a fd\b\a\1.txt fd\b\a\a\ fd\b\b\1.txt fd\b\b\a Ruslan F. string[] allfiles = Directory.GetFiles("path/to/dir", "*.*", SearchOption.AllDirectories); where *.* is pattern to match files If the

How to exclude folders when using Directory.GetDirectories

拜拜、爱过 提交于 2019-11-28 05:51:02
问题 I want to return a list of all the subdirectories in the 'SomeFolder' directory excluding the 'Admin' and 'Templates' directories. I have the following folder structure (simplified): C:\inetpub\wwwroot\MyWebsite\SomeFolder\RandomString C:\inetpub\wwwroot\MyWebsite\SomeFolder\RandomString C:\inetpub\wwwroot\MyWebsite\SomeFolder\RandomString C:\inetpub\wwwroot\MyWebsite\SomeFolder\Admin C:\inetpub\wwwroot\MyWebsite\SomeFolder\Templates 'SomeFolder' can contain a varying number a 'RandomString'

List all files and directories in a directory + subdirectories

橙三吉。 提交于 2019-11-27 10:04:01
问题 I want to list every file and directory contained in a directory and subdirectories of that directory. If I chose C:\ as the directory, the program would get every the name of every file and folder on the hard drive that it had access to. A list might look like fd\1.txt fd\2.txt fd\a\ fd\b\ fd\a\1.txt fd\a\2.txt fd\a\a\ fd\a\b\ fd\b\1.txt fd\b\2.txt fd\b\a fd\b\b fd\a\a\1.txt fd\a\a\a\ fd\a\b\1.txt fd\a\b\a fd\b\a\1.txt fd\b\a\a\ fd\b\b\1.txt fd\b\b\a 回答1: string[] allfiles = Directory