zimmer9
asked on
I am writing a C# console application and exit the app if a "txt" file is not present. However, the exe ALWAYS exits the app whether or not a "txt" file exists.
I am writing a C# console application using VS2015 and .Net Framework 4.6
I want to exit the application if the input "txt" file is not present in the directory \\NY\data\
Whether or not a txt file is present in the directory, the application takes the exit path.
What am I doing wrong in the following code?
public static class MyGlobals
{
public static string BASE_DIR = @"\\NY\data\";
string inputTxtFilePath = MyGlobals.BASE_DIR + "*" + ".txt";
if (File.Exists(inputTxtFileP ath))
{
}
else
{
StreamWriter sw2 = new StreamWriter(errorFilePath );
sw2.WriteLine("Input txt File not found");
if (sw2 != null) sw2.Close();
Environment.Exit(0);
}
I want to exit the application if the input "txt" file is not present in the directory \\NY\data\
Whether or not a txt file is present in the directory, the application takes the exit path.
What am I doing wrong in the following code?
public static class MyGlobals
{
public static string BASE_DIR = @"\\NY\data\";
string inputTxtFilePath = MyGlobals.BASE_DIR + "*" + ".txt";
if (File.Exists(inputTxtFileP
{
}
else
{
StreamWriter sw2 = new StreamWriter(errorFilePath
sw2.WriteLine("Input txt File not found");
if (sw2 != null) sw2.Close();
Environment.Exit(0);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
bool exist = Directory.EnumerateFiles(M