Nextrp [CPP] RU + Many GEOs Игра на карте России | NEXTRP

C# Code doesn’t compile verifying files before process start

c# sha1

70 просмотра

1 ответ

40 Репутация автора

I am new to C# trying to get what I hoped might be a simple little script to check the working directory for the existence of test.mdb and then if it exists check the sha1 of MyVbs against MySha and if they’re the same go on to process.Start. Below is my cs file which I write in notepad and compile with framework 3.5 csc.exe

I have reposted my problem having tried all the various and many SO sha1 codes none of which I can get to work with my code and all of which seem to be quite different and specific to certain needs. I settled for the one I thought most appropriate to my situation and incorporated it in to my code but I can’t get it to work? So if anyone can help sort out the problem with my code so that it does work rather than just banning my question it would be very helpful for my learning C#. Thank you.

using System;
using System.IO;
using System.Windows.Forms;
using System.Diagnostics;
using System.Reflection;
using System.Security.Cryptography;


class MyClass {
    static void Main()
var filePath = @"test.mdb";
var MyVbs = @"MyScript.vbs";
var MySha = "d0be2dc421be4fcd0172e5afceea3970e2f3d940";

if (File.Exists(filePath))

using(var cryptoProvider = new SHA1CryptoServiceProvider())
    string hash = BitConverter

if MyVbs = MySha // This needs changing to make sha1 check but how?
        Process process = new Process();
        process.StartInfo.FileName = MyVbs;
    MessageBox.Show("The sha1 doesn't match. The file has been altered.","My Title");

    MessageBox.Show("File doesn't exist","My Title");
Автор: p deman Источник Размещён: 13.03.2017 01:38

Ответы (1)

0 плюса

3939 Репутация автора


As other suggested, you should really use Visual Studio (Community for free edition). There are some obvious syntax errors like :

if MyVbs = MySha 

Which should be :

if (MyVbs == MySha)

for proper syntax.

And which should REALLY be :

if (hash == MySha)

According to what this part of code is supposed to do according my guess.

There are probably some other errors in your code.

Автор: AFract Размещён: 13.03.2017 01:53
Вопросы из категории :