I am new to coding. Started creating my 1st windowsservice to zip files from a certain location please review this code
The zip file is not created in the appropriate location of output folder in path2.
Please help me in this regard also attaching the logs at the end..
Please help need assistance from you guys
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.IO;
using System.Timers;
using ICSharpCode.SharpZipLib.Core;
using ICSharpCode.SharpZipLib.Zip;
namespace WindowsServiceZip
{
public partial class WindowsServiceZip : ServiceBase
{
Timer timer;
string path1 = @"D:\Zipped_Files\New_Text_Document.txt";
string path2 = @"D:\output\filezipname.7z";
string path3 = @"D:\Zipped_Files\R_23122015.txt";
int timerInterval = 60000;
public WindowsServiceZip()
{
InitializeComponent();
timer = new Timer();
timer.Elapsed += new ElapsedEventHandler(this.timer_Elapsed);
timer.Interval = timerInterval;
timer.Enabled = true;
}
protected override void OnStart(string[] args)
{
timer.Start();
}
protected override void OnStop()
{
timer.Stop();
timer.SynchronizingObject = null;
timer.Elapsed -= new ElapsedEventHandler(this.timer_Elapsed);
timer.Dispose();
timer = null;
}
public void timer_Elapsed(object sender, ElapsedEventArgs e)
{
ZipFile z = ZipFile.Create(path2);
z.BeginUpdate();
z.Add(path1);
z.Add(path3);
z.CommitUpdate();
z.Close();
}
}
}
After running vs developer cmd prompt and installing in installutil.exe windowsservicezip.exe i am getting the following log file but zip is not getting created
Running a transacted installation.
Beginning the Install phase of the installation.
See the contents of the log file for the D:\vs_wpf\WindowsServiceZip\WindowsServiceZip\bin\Debug\WindowsServiceZip.exe assembly's progress.
The file is located at D:\vs_wpf\WindowsServiceZip\WindowsServiceZip\bin\Debug\WindowsServiceZip.InstallLog.
The Install phase completed successfully, and the Commit phase is beginning.
See the contents of the log file for the D:\vs_wpf\WindowsServiceZip\WindowsServiceZip\bin\Debug\WindowsServiceZip.exe assembly's progress.
The file is located at D:\vs_wpf\WindowsServiceZip\WindowsServiceZip\bin\Debug\WindowsServiceZip.InstallLog.
The Commit phase completed successfully.
The transacted install has completed.