Im a beginner, and If statements are my weakness. I have a simple program that displays files names that are located in a certain folder. However, some files might have lines that begin with LIFT. I want to catch those files that have that certain line, and display the file name in a different color (preferably red). Here is what I have so far: Any assistance would be greatly appreciated!! Thanks!
public partial class ShippedOrders : System.Web.UI.Page
{
class Program
{
static void Main()
{
string[] array1 = Directory.GetFiles(@"C:\Kaplan\Replies\");
string[] array2 = Directory.GetFiles(@"C:\Kaplan\Replies\", "*.REP");
Console.WriteLine("---Files:---");
foreach (string name in array1)
{
Console.WriteLine(name);
}
Console.WriteLine("---REP Files: ---");
foreach (string name in array2)
{
Console.WriteLine(name);
}
}
}
}
Directory.GetFiles(directoryPath) will return an array of strings listing the file names (full paths) within that directory. You’re going to have to actually open and read each file, using the string array returned. Read each file line by line in a loop and test if any lines begins with “LIFT”.
Also the way you set up your code-behind for this webpage is funky. You’re declaring a class inside the partial class of the page. Try setting up your code like this: