1
I want to know if there is any way I can create a form to be opened only the first time the program runs. Because the form must create a file in the system with login the first time the program runs only, it cannot create the file whenever the user opens the program because if the login has been changed it will be changed again to the default.
Another option would be to create the file at the time of installing the program but do not know how to do it, I already researched enough and found nothing.
There’s no code because I couldn’t do anything, I just tried to put File.Create("caminho");
on splash screen, but it always creates a new file and replaces the old one thus losing the information recorded in it.
Tried to create a boolean global variable?
– Guilherme Nascimento
do a check! if with
File.Create("path")
work, do something like thatFileStream f = File.Open("path")
and you give the conditionIf (f.exist) "exacuta A" else executa B"
create a function withFileStream()
to check if the file exists.– Hebert Lima
Had not tried with global variable, I decided to try Helbert’s method first, because variable were resetting its value when the program was restarted (but I did not use global) .. Well the Helbert method worked, I just had to research, actually it’s not Filestream or File.Open.. I’ll leave the answer below..
– Leonardo
Now there is the question of how to create forms to be executed only the first time, but with file you can control better.. I think it would be something like this, in the first run, it shows the form and after the user click on the continue button for example, delete the form forever or change the program startup form
– Leonardo
my fault! is
FileInfo
I used it once for a similar problem, and I tried to respond in my head, but that’s it and... it is possible to control this if your application has database, or you can use thesetings
of the project.– Hebert Lima