I have an app that loops thru video files of various extensions and converts them. I had the list of extensions hard coded during testing:
- string[] extensions = { ".mp4", ".mov", ".avi", ".mpg", ".wmv", ".mkv", ".m4v" };
That is used in my loop as:
- foreach (string file in Directory.EnumerateFiles(rootfolder, "*.*", searchOption)
- .Where(s => extensions.Any(ext => ext == Path.GetExtension(s))))
Works fine.
I tried adding it to my appname.config in several ways:
version="1.0" encoding="utf-8" ?> - <configuration>
- <startup>
- <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
- startup>
- <appSettings>
- <add key="extensionstest" value="".mp4",".mov",".avi",".mpg",".wmv",".mkv",".m4v"" />
- appSettings>
- >
Tried the above with ampersand quote semicolon and without any quotes so with the period and the extension name but it doesn't seem to parse it on output. It may actually do the first one but not 100% sure.
Tried retrieving it in several fashions but latest was:
- string[] extensions = ConfigurationManager.AppSettings["extensionstest"].Split(',');
Any help with the most efficient way to do this or do I need to hard code this and recompile if new extensions come up I need to handle?
Thanks.
JR
Ganesan CPosted Aug 11, 2021, 12:04 PM
Priyanka K SPosted Aug 11, 2021, 11:41 AM
John RikerPosted Oct 29, 2020, 10:36 AM
Sachin SinghPosted Oct 29, 2020, 10:30 AM