Hello my console app is for downloading html files and then sending it to a txt file, after the process is complete I would like the app to verify if the file was created and then close the program after telling the user that the page downloaded. I would like to ask how to verify if file exists and then how to exit the app.
Console.WriteLine("Enter a Valid Webpage URL such as http://wwww.google.com, this tool will download the HTML into a .txt file");
string webPage = Console.ReadLine();
Uri uriResult;
bool result = Uri.TryCreate(webPage, UriKind.Absolute, out uriResult)
&& (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
WebClient client = new WebClient();
//DownloadsWebpage
string reply = client.DownloadString(webPage);
Console.WriteLine(reply);
//Location of file here
Console.WriteLine("Please enter a valid address to save the .txt file such as C:\\Users\\Public\\String.txt, then press any button to exit");
string txtDir = Console.ReadLine();
File.WriteAllText(txtDir, reply);
Console.ReadLine();