using System; using System.IO; using System.Linq; using System.Windows.Forms; namespace CopyAndEncodeImage { internal static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main(params string[] args) { if (args.Count() > 0) { // If there are command line arguments, pass them to the form if (Path.GetExtension(args[0].ToLower()) != ".png") { MessageBox.Show("Please provide a valid PNG file as the first argument.", "Invalid File", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var bytes = File.ReadAllBytes(args[0]); string base64String = Convert.ToBase64String(bytes); //string base64String = new string(base64Chars); string output = $"data:image/png;base64,{base64String}"; Clipboard.SetText(output); } else { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } } }