示例#1
0
        static void Main()
        {
            string fileName;

            Console.Write("Please type in the name of the file " +
                          "containing the names of the people to be cold-called > ");
            fileName = Console.ReadLine();
            ColdCallFileReader peopleToRing = new ColdCallFileReader();

            try
            {
                peopleToRing.Open(fileName);
                for (int i = 0; i < peopleToRing.NPeopleToRing; i++)
                {
                    peopleToRing.ProcessNextPerson();
                }
                Console.WriteLine("All callees processed correctly");
            }
            catch (FileNotFoundException e)
            {
                Console.WriteLine("The file {0} does not exist", fileName);
            }
            catch (ColdCallFileFormatException e)
            {
                Console.WriteLine(
                    "The file {0} appears to have been corrupted", fileName);
                Console.WriteLine("Details of problem are: {0}", e.Message);
                if (e.InnerException != null)
                {
                    Console.WriteLine(
                        "Inner exception was: {0}", e.InnerException.Message);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception occurred:\n" + e.Message);
            }
            finally
            {
                peopleToRing.Dispose();
            }
            Console.ReadLine();
        }
示例#2
0
      static void Main()
      {
          Console.Write("Please type in the name of the file " +
            "containing the names of the people to be cold-called > ");
         string fileName = Console.ReadLine();
         ColdCallFileReader peopleToRing = new ColdCallFileReader();

         try
         {
            peopleToRing.Open(fileName);
            for (int i=0 ; i<peopleToRing.NPeopleToRing; i++)
            {
               peopleToRing.ProcessNextPerson();
            }
            Console.WriteLine("All callees processed correctly");
         }
         catch(FileNotFoundException)
         {
            Console.WriteLine("The file {0} does not exist", fileName);
         }
         catch(ColdCallFileFormatException e)
         {
            Console.WriteLine(
          "The file {0} appears to have been corrupted", fileName);
            Console.WriteLine("Details of problem are: {0}", e.Message);
            if (e.InnerException != null)
               Console.WriteLine(
                  "Inner exception was: {0}", e.InnerException.Message);
         }
         catch(Exception e)
         {
            Console.WriteLine("Exception occurred:\n" + e.Message);
         }         
         finally
         {
            peopleToRing.Dispose();
         }
         Console.ReadLine();
      }