Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Console.WriteLine("Postal Code Checker");
- string postalChecker = @"C:\Users\Student\Desktop\New folder (2)\PostalCodes.txt";
- int counter = 0;
- Regex pattern = new Regex(@"\d{6,6}");
- StreamReader reader = new StreamReader(postalChecker);
- if (File.Exists(postalChecker))
- {
- Console.WriteLine("File Exist");
- while ((postalChecker = reader.ReadLine()) != null)
- {
- foreach (Match m in pattern.Matches(postalChecker))
- if(m.Success)
- {
- if ((postalChecker.Substring(0,2) == "73") && (postalChecker.Length == 6))
- {
- Console.WriteLine(postalChecker);
- Console.WriteLine("Postal district is: 25");
- counter++;
- }
- else if ((postalChecker.Substring(0, 2) == "72") && (postalChecker.Length == 6))
- {
- Console.WriteLine(postalChecker);
- Console.WriteLine("Postal district is: 25");
- counter++;
- }
- else if ((postalChecker.Substring(0, 2) == "56") && (postalChecker.Length == 6))
- {
- Console.WriteLine(postalChecker);
- Console.WriteLine("Postal district is: 20");
- counter++;
- }
- else if ((postalChecker.Substring(0, 2) == "57") && (postalChecker.Length == 6))
- {
- Console.WriteLine(postalChecker);
- Console.WriteLine("Postal district is: 20");
- counter++;
- }
- else if ((postalChecker.Substring(0, 2) == "75") && (postalChecker.Length == 6))
- {
- Console.WriteLine(postalChecker);
- Console.WriteLine("Postal district is: 27");
- counter++;
- }
- else if ((postalChecker.Substring(0, 2) == "76") && (postalChecker.Length == 6))
- {
- Console.WriteLine(postalChecker);
- Console.WriteLine("Postal district is: 27");
- counter++;
- }
- else
- {
- Console.WriteLine(postalChecker);
- Console.WriteLine("District does not exist!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement