The code's indentation is pretty terrible. Keeping a good indentation is the key to keep maintainable code. With any good IDE, you can auto-format your code!
Also, considering the naming conventions, your variables should be
FullList -> fullList. And
subFile holds multiple files, so you should pluralize it!
subFile -> subFiles
You should import the
System.IO instead of typing
System.IO.Path.HasExtension all the time.
You do this using
using System.IO; (if you didn't know already).
Instead of having :
You should use the
else statement :
As @Heslacher pointed out, you should use the
AddRange method, it does the same thing as :
for (int io = 0; io < subFile.Length; io++)
So well, that's less code! :)
You shouldn't call
Directory.GetFiles(FullList[i]) twice. It's the most costly operation in your code, so you should call it only once! Same thing for
Instead of typing
fullList[i] all the time, you should create a variable to hold it! Not that accessing an array is that expansive, but well, it'll help for readability.
So, let's check the final code :
List<string> fullList = new List<string>(LoadFiles("patch.txt"));
List<string> shortCatalogList = new List<string>();
List<string> shortFileList = new List<string>();
for (int i = 0; i < fullList.Count; i++)
string path = fullList[i];
string subFiles = Directory.GetFiles(path);
string subFolders = Directory.GetDirectories(path);
if (subFiles.Length > 0)
if (subFolders.Length > 0)