C# and Rebooting a Raspberry Pi

C# and Rebooting a Raspberry Pi

Every now and again, you need to restart a Raspberry Pi from within your application. This is typically done after making changes to the Pi configuration, issuing commands to enable or disable GPIO pins and many other things.

Fortunately, if you are writing your code using C# – and I am – this is straightforward. You simply write the following statements: –

System.Diagnostics.Process.Start(new ProcessStartInfo() {FileName = "sudo", Arguments = "reboot"});

This issues the sudo command and passes the reboot command to it as an argument.

Stephen

Hi, my name is Stephen Finchett. I have been a software engineer for over 30 years and worked on complex, business critical, multi-user systems for all of my career. For the last 15 years, I have been concentrating on web based solutions using the Microsoft Stack including ASP.Net, C#, TypeScript, SQL Server and running everything at scale within Kubernetes.