Why does my code won't trigger the else condition? If I can't locate my file it won't prompt, but if it locate it prompts.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string path = @"C:\Personal Folders\";
string[] files = Directory.GetFiles(path,
"*3.zip*", //set sa batch
SearchOption.AllDirectories);
// Display all the files.
foreach (string file in files)
{
bool exist = File.Exists(file);
if (exist == true)
{
MessageBox.Show("File Located : " + Convert.ToString(file));
}
else
{
MessageBox.Show("File Cant Locate :");
}
}
}