Add project files.
This commit is contained in:
36
Program.cs
Normal file
36
Program.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CopyAndEncodeImage {
|
||||
internal static class Program {
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[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());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user