File Search C#

Code that I wrote for a first year project that involved us looking though directories and files using c#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Assignment___Daniel_MacArthur
{
class Program
{

//variables
static bool ProgramRunning = true;
static DirectoryInfo folderInfo = new DirectoryInfo("C:\\Windows"); //default directory
static bool Validinput = false;
static int result; //users menu selection
static int MenuNum = 6; //number of options in menu
static FileInfo[] files = folderInfo.GetFiles();

static void FileInfo(string filter) //Gets information of a single file
{
bool ValidationLoop = false;
while (!ValidationLoop)
{
FileInfo[] files = folderInfo.GetFiles(filter); //applies filter, if there is one

//Ask to input a number
Console.WriteLine("Type a file number for more info or type 0 return to menu: ");
string FileNumber = Console.ReadLine();

//number validation
int FileIndex;
bool IsNumber = int.TryParse(FileNumber, out FileIndex);
while (!IsNumber)
{
Console.WriteLine("That is not a number, please try again: ");
FileNumber = Console.ReadLine();
IsNumber = int.TryParse(FileNumber, out FileIndex);
}

Console.WriteLine();
//Correct number validation
if (FileIndex == 0)
{
ValidationLoop = true;
}

else if (FileIndex > files.Length || FileIndex < 0)
{
Console.WriteLine("That number is not in range, please choose a number between 0 and {0}", files.Length);
}

else
{
ValidationLoop = true;
Console.WriteLine("File: {0}", files[FileIndex-1].Name);
Console.WriteLine("Full File Name: {0}\\{1}", folderInfo, files[FileIndex - 1].Name);
Console.WriteLine("File sie: {0} bytes", files[FileIndex - 1].Length);
Console.WriteLine("Created: {0}", files[FileIndex-1].CreationTimeUtc);
Console.WriteLine("Last accessed: {0}", files[FileIndex - 1].LastAccessTimeUtc);
}

}
}

static void Main(string[] args)
{
while (ProgramRunning)
{
//menu loop
do
{
//list of options
Console.WriteLine("Welcome to File Explorer");
Console.WriteLine();
Console.WriteLine("Current folder {0}", folderInfo);
Console.WriteLine();
Console.WriteLine("--- Menu --- ");
Console.WriteLine("1.Full File Listing");
Console.WriteLine("2.Filtered File Listing");
Console.WriteLine("3.Folder Statistics");
Console.WriteLine("4.Quit");
Console.WriteLine("5.Change Current Folder");
Console.WriteLine("6. 1Mb (1048576) search");

string MenuInput = Console.ReadLine();

//input validation
bool MenuOutput = int.TryParse(MenuInput, out result); //checks if input was a number

if (MenuOutput && result <= MenuNum && result > 0) //exits menu loop and executes code according to input
{
Console.Clear();
Validinput = true;
}

else //informs user that there input is incorrect
{
Console.Clear();
Console.WriteLine("You must input a number between 1 and {0}", MenuNum);
Console.WriteLine("Press enter to try again");
Console.ReadLine();
Console.Clear();
}

} while (!Validinput);

//full file listing
if (result == 1)
{
FileInfo[] files = folderInfo.GetFiles();
Console.WriteLine("Files in {0}", folderInfo);
for (int index = 0; index < files.Length; index++)
{
Console.WriteLine("{0}. {1} ({2})", index + 1, files[index].Name, files[index].Length);
}
FileInfo("*.*");
}

//filtered file listing
else if (result == 2)
{
Console.WriteLine("Please, enter the filter (format *.*): ");

string Filter = Console.ReadLine();

FileInfo[] files = folderInfo.GetFiles(Filter);

Console.WriteLine("Files in {0} with the filter: {1}", folderInfo, Filter);

for (int index = 0; index < files.Length; index++)
{
Console.WriteLine("{0}. {1} ({2})", index + 1, files[index].Name, files[index].Length);

}

FileInfo(Filter);

}

//directory info
else if (result == 3)
{
Console.WriteLine("Files in: {0}", folderInfo);
Console.WriteLine("Total files: {0} ", files.Length);

long TotalFileSize = 0;

for (int index = 0; index < files.Length; index++)
{
TotalFileSize = TotalFileSize + files[index].Length;
}

Console.WriteLine("Total size of all files: {0} bytes", TotalFileSize);

long BiggestFileSize = 0;
string BiggestFileName = "";

//loop though files to find the largest file
for (int index = 0; index < files.Length; index++)
{
if (files[index].Length > BiggestFileSize)
{
BiggestFileSize = files[index].Length;
BiggestFileName = files[index].Name;
}
}

Console.WriteLine("Largest file: {0}, {1} bytes", BiggestFileName, BiggestFileSize);
long AverageFileSize = TotalFileSize / files.Length;
Console.WriteLine("Average file Length: {0} bytes", AverageFileSize);
}

//exit
else if (result == 4)
{
Environment.Exit(0);
}

//Change current directory
else if (result == 5)
{
Console.WriteLine("Please enter the new path:");
string FilePath = Console.ReadLine();
folderInfo = new DirectoryInfo(FilePath);
Console.WriteLine("The new file path is now: {0}", FilePath);
}

//find file with 1mb of a given number, 1mb = 1048576 bytes
else if (result == 6)
{
long SizeInMB = 0;
bool IsInt = false;
do
{
Console.WriteLine("size of file in bytes: ");
string FileSize = Console.ReadLine();
IsInt = long.TryParse(FileSize, out SizeInMB);

if (!IsInt)
{
Console.WriteLine("[Error:] Input must be a number");
}
} while (!IsInt);

FileInfo[] files = folderInfo.GetFiles();
Console.WriteLine("Files with in a 1mb range of {0} in folder {1}", SizeInMB, folderInfo);

int Position = 1;
for (int index = 0; index < files.Length; index++)
{
if (files[index].Length < (SizeInMB + 1048576) && files[index].Length > (SizeInMB - 1048576))
{
Console.WriteLine("{0}. {1} ({2})", Position, files[index].Name, files[index].Length);
Position++;
}
}
}

//loop program
Console.WriteLine();
Console.WriteLine("Press enter to return to menu...");
Console.ReadLine();
Console.Clear();
Validinput = false;
}
}
}
}