/
Program.cs
31 lines (27 loc) · 1.66 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
private static void Main(string[] args)
{
if (File.Exists(new AppSettingsReader().GetValue("oldfile", Type.GetType("System.String")).ToString()))
{
new WebClient().DownloadFile(new AppSettingsReader().GetValue("URL", Type.GetType("System.String")).ToString(), new AppSettingsReader().GetValue("newfile", Type.GetType("System.String")).ToString());
if (new FileInfo(new AppSettingsReader().GetValue("oldfile", Type.GetType("System.String")).ToString()).Length != new FileInfo(new AppSettingsReader().GetValue("newfile", Type.GetType("System.String")).ToString()).Length)
{
SendMail();
File.Delete(new AppSettingsReader().GetValue("oldfile", Type.GetType("System.String")).ToString());
File.Copy(new AppSettingsReader().GetValue("newfile", Type.GetType("System.String")).ToString(), new AppSettingsReader().GetValue("oldfile", Type.GetType("System.String")).ToString());
}
}
else
{
new WebClient().DownloadFile(new AppSettingsReader().GetValue("URL", Type.GetType("System.String")).ToString(), new AppSettingsReader().GetValue("oldfile", Type.GetType("System.String")).ToString());
SendMail();
}
}
private static void SendMail()
{
if (File.Exists(new AppSettingsReader().GetValue("newfile", Type.GetType("System.String")).ToString()))
{
MailMessage message = new MailMessage("from@example.com", "to@enduser.com", "New Ohio Liquor List", "Attached is the new list of liquor");
message.Attachments.Add(new Attachment(new AppSettingsReader().GetValue("newfile", Type.GetType("System.String")).ToString()));
new SmtpClient("localhost", 25).Send(message);
}
}