Robson Amaral

Robson Amaral

  • NA
  • 132
  • 15.7k

Questions regarding reading files

Apr 20 2018 7:47 AM
I have my service code already ready, but inside it, I should get the first file containing the extension .cpv, in case I read this file, inside the file it contains several vouchers with its due information, however, I need to save the data it contains on each voucher, such as date and time, document value, as soon as I finish processing this file, I have to move those files to another folder. How could I be initiating this coding of this application? Because in my windows service project, I already have two classes LogService and Program.cs, already ready, as it is a windows service, how could I apply these requirements in this windows functionality, to read those files in that directory? Would you kindly help me, friend?
 
Here's my service code:
 
Service1.cs
  1. using System;    
  2. using System.Collections.Generic;    
  3. using System.ComponentModel;    
  4. using System.Data;    
  5. using System.Diagnostics;    
  6. using System.IO;    
  7. using System.Linq;    
  8. using System.ServiceProcess;    
  9. using System.Text;    
  10. using System.Threading.Tasks;    
  11. using System.Timers;    
  12.     
  13. namespace ServicoProcessamentoComprovantes    
  14. {    
  15.     public partial class Service1: ServiceBase    
  16.     {    
  17.         private Timer timer1 = null;    
  18.         public Service1 ()    
  19.         {    
  20.             InitializeComponent ();    
  21.         }    
  22.     
  23.         protected override void OnStart (string [] args)    
  24.         {    
  25.             LogService.writeEventLog ("The timer is set to 10 seconds");    
  26.             timer1 = new Timer ();    
  27.             // 1000 = one seconds    
  28.             this.timer1.Interval = 1000; // 10 seconds    
  29.             this.timer1.Elapsed + = new ElapsedEventHandler (this.timer_tick);    
  30.             this.timer1.Enabled = true;    
  31.             LogService.writeEventLog ("Starting Banestes service");    
  32.         }    
  33.     
  34.         private void timer_tick (object sender, ElapsedEventArgs e)    
  35.         {    
  36.             // ALL:    
  37.             LogService.writeEventLog ("The timer and some operations are running ...");    
  38.             // ALL:    
  39.     
  40.             LogService.writeEventLog ("Operation completed successfully");    
  41.         }    
  42.         protected override void OnStop ()    
  43.         {    
  44.             LogService.writeEventLog ("******** --Event: Idle-- ********");    
  45.             LogService.writeEventLog ("Attempt to Stop Service");    
  46.             timer1.Stop ();    
  47.             timer1 = null;    
  48.             LogService.writeEventLog ("Service stopped by user");    
  49.         }    
  50.         private void ListArchives ()    
  51.         {    
  52.             string extension = Path.GetExtension ("");    
  53.             DirectoryInfo Dir = new DirectoryInfo (@ "\\ S3A601 \ ftp @ sefaz \ BANESTES \ Output_SDPJ \ test");    
  54.         }    
  55.     }    
  56. }