Welcome to cup of dev

All post publised as Morné Wolfaardt

Starting Docker Containers After a Host Restart

I’ve recently started learning Docker, and how to run Docker on a Raspberry PI 3. I soon realized that whenever the host shuts down, or restarts the Docker containers will not restart automatically. I know you can set the container to auto start but if you are a Noob like me, you can use the following to get the containers back up and running. docker ps -a The command docker ps -a will list all the containers event the once that are not running.

Compress files and folders using sevenzipsharp and 7-Zip in C-Sharp

Compressing files using 7-Zip and seven zip sharp ( is really easy. To get started you would need the 7-Zip DLL namespace Cupofdev { using System; using System.IO; using SevenZip; class Cupofdev { static void Main(string[] args) { // Set source and target folders string targetFolder = @"E:\CodeDumps"; string sourceCodeFolder = @"C:\Dev\Clients\cupofdev"; if (System.IO.Directory.Exists(targetFolder)) { // Specify where 7z.dll DLL is located SevenZipCompressor.SetLibraryPath(@"C:\Program Files\7 - Zip\7z.dll"); SevenZipCompressor sevenZipCompressor = new SevenZipCompressor(); sevenZipCompressor.

Sending Email Using Office 365 Exchange Webservices Api

Sending email using C# is really easy, you can use the build in SMTP client // Setup mail message section MailMessage mailMessage = new MailMessage(); mailMessage.From = new MailAddress("[email protected]"); mailMessage.To.Add(new MailAddress("[email protected]"); mailMessage.Subject = "Test Message Subject"; mailMessage.Body = "HTML Body; mailMessage.IsBodyHtml = true; // Setup SMTP Client SmtpClient client = new SmtpClient(); client.Credentials = new NetworkCredential("", ""); client.Port = 587; client.Host = ""; client.EnableSsl = true; client.send(mailmessage); but using this method will send email using the SMTP setting for Exchange Online / Office 365.

Log Data to a File

You can easily write a collection of data to a log file by using System.IO.File.WriteAllLines method.System.IO.File.WriteAllLines The File.WriteAllLines method take two parameters, the output file and a collection of string entries. The method writes each entry on a new line. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace Cupofdev { class Cupofdev { static void Main(string[] args) { // Create a list and populate it. List<string> lstEntry = new List<string>(); lstEntry.