I've an array. Let's say;
- private string[] WhiteList =
- {
- "abcxyz.cs",
- "mouseapi.dll",
- "SensitivtyFix.asi",
- "drake.mp3"
- };
Another array,
- private string[] SuspectedFiles =
- {
- ".cs",
- "d3d9.dll",
- "sqlite3.dll",
- "mod_sa.ini",
- "mod_sa.raw",
- ".cleo",
- ".asi"
- };
Now I want to exclude WhiteList array from a directory/file search. How do I achieve that?
For this search, I'm using another array called SuspectedFiles as mentioned above from which I could fetch desired files but I'm unable to exclude files from the array Whitelist.
This is my code;
I could get results of files from SuspectedFiles array but couldn't remove files contained in Whitelist array from the search results.
- private void VerifySuspectedFiles()
- {
- listBox1.Enabled = true;
-
- DirectoryInfo DirInf = new DirectoryInfo(GetGtaRegistryPath());
- int GetSize = SuspectedFiles.GetLength(0);
-
- if (!DirInf.Exists)
- {
- MessageBox.Show("This directory does not exist!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
-
- return;
- }
-
- if (GetSize == 0)
- {
- return;
- }
-
- for (int i = 0; i < GetSize; ++i)
- {
- foreach (var File in DirInf.GetFiles("*", SearchOption.AllDirectories))
- {
- if (File.FullName.Contains(SuspectedFiles[i]) && !File.FullName.Contains(WhiteList[i]))
-
- {
- listBox1.Items.Add("File: " + File.FullName);
- }
- }
- }
- }
Any help would be great. Thank You.