c# - Only start Project if File Exists -
i have 2 different executables, 1 login , other main application.
now, want make possible open login, not main program. right can open main app clicking on it.
the login app creates small txt file information, , main program starts , deletes file.
is there way make main program start if 1 file exists? nobody can start main app without login first.
so, when login, app checks mysql database if account exists. runs:
string übergabeparameter = convert.tostring(typ); string filename = (@"c:\users\viuser\desktop\test\dat.exe"); var proc = system.diagnostics.process.start(filename, übergabeparameter); using (system.io.streamwriter sw = system.io.file.createtext("fluff.txt")) { sw.write(benutzername + system.environment.newline + typ); } close();
then dat.exe starts, , runs this:
bürgerlichername = file.readlines("fluff.txt").first(); string line = file.readlines("fluff.txt").skip(1).take(1).first(); if (line == "1") { typ = "trainer"; } else { typ = "lehrling"; }; system.io.file.delete("fluff.txt");
i created both apps in visual studio wpf , c#.
in startup code main app check file. if file don't exist can message user launch correct exe (login). have login add kind of hash code main program knows login legit protect against faking login or maybe old txt file didn't deleted after previous login (main org might have crashed or other abend before deleting file.)
Comments
Post a Comment