TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sai Parthiv
NA
11
709
How to exclude an array from search in C#
May 16 2017 4:04 AM
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.
Reply
Answers (
1
)
Crystal Report Memory Full Error
HTTP Error 500.19 - Internal Server Error in IIS