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
Steve DeYoung
NA
12
0
Looping through an array
Jul 14 2017 12:31 AM
I am trying to loop through an array. The array is filled with names from a text file. If the name isn't in the array I want to skip it and continue looping. This is what I have so far.. The problem i'm having is when the name doesn't exist the loop ends and falls into the catch.
try
{
string[] file = File.ReadAllLines(@"C:\Users\Steve\Documents\Visual Studio 2015\Projects\FileCopier\FileCopier\File.txt");
foreach(string folder in file)
{
if (file.Contains(folder))
{
Directory.Move(Path.Combine(sourceDirectory, folder), Path.Combine(destinationDirectory, folder));
}
else
{
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Reply
Answers (
4
)
Compile type error coming in List.
I don't know how to use Generics on matrix operations