My code below should check the working directory for the existence of test.mdb and then if it exists it should check the sha1 of MyVbs against MySha and if they’re the same it should go on to process.Start.
What code do I need to make this (if MyVbs = MySha) work? I’m using notepad to build my cs file and framework 3.5 csc.exe to compile it so please only code which is compatible with my setup. Thank you for any help.
using System;
using System.IO;
using System.Windows.Forms;
using System.Diagnostics;
using System.Reflection;
using System.Security.Cryptography;
[assembly:AssemblyVersionAttribute("1.0.0.0")]
[assembly:AssemblyTitleAttribute("MyTitle")]
[assembly:AssemblyDescriptionAttribute("MyDescription")]
[assembly:AssemblyCompanyAttribute("MyCompany")]
[assembly:AssemblyFileVersionAttribute("1.0.0.0")]
[assembly:AssemblyProductAttribute("MyProduct")]
class MyClass {
static void Main()
{
var filePath = @"test.mdb";
var MyVbs = @"MyScript.vbs";
var MySha = "d0be2dc421be4fcd0172e5afceea3970e2f3d940";
if (File.Exists(filePath))
{
if MyVbs = MySha // This needs changing to make sha1 check but how?
{
Process process = new Process();
process.StartInfo.FileName = MyVbs;
process.Start();
}
else
{
MessageBox.Show("The sha1 doesn't match. The file has been altered.","My Title");
}
}
else
{
MessageBox.Show("File doesn't exist","My Title");
}
}
}