1
Someone could help me, I’m trying to check if the execultavel was renamed, like
Demo.exe (has to be like this always)
if change it give error The Archive must have the name 'Demo'.
and not allow opening the file if it does not have the right name.
the problem I’m not knowing how to do the check...
in my code you can check if it is in the folder, but if you have a Demo and another with any name it opens...
follows the code.
private string ExecutablePath = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
if (File.Exists(ExecutablePath + @"\Demo.exe"))
{
}
else
{
MessageBox.Show("O Arquivo deve ter o nome \'Demo\'.", "Error");
Environment.Exit(0);
}
from now on thanks.
this way the most that will do is to check if the file exists in the folder, can not see to be changed if you do not know the name. The closest to this would be to make an application that is running all the time and monitor the folder to see when something changes, but if it stops for some reason it will lose the changes. That’s what class is for
FileSystemWatcher
– Ricardo Pontual
No no, I wanted to soh allow the file to open if it has the name Demo.exe, otherwise the error. whenever open check whether the name is correct, if changing it does not execute.
– Rodrigo Pretti Fantin
Ah understood, see if this resolves, then I can post a more detailed answer:
if (System.AppDomain.CurrentDomain.FriendlyName == "Demo.exe")
– Ricardo Pontual
would be +/- this msm, however I am not able to put this code in Demo.exe, if it is in another right form, but in it does not open the file itself, but it generates the error if you change the name...
– Rodrigo Pretti Fantin
but if it works the
FrindlyName
you already have to compare, now if you are giving error is another problem. Which error occurs?– Ricardo Pontual
@Ricardopunctual worked, it was a mistake my kkk
– Rodrigo Pretti Fantin
OK, I left as answer below. good luck!
– Ricardo Pontual