Click here to Skip to main content
15,899,754 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In this program, I first set the variable isSuccess to false. After the program run successfully, the variable will become true.

The next thing that I want to continue is for the next time, before start to run the program, I need to get the variable first. If the variable belongs to true, proceed with the program, else the program will stop.

How I get the 'true' variable when I run it next time and let the program know that it should proceed since the variable is true? as I had set the default variable to false. Any suggestion?

What I have tried:

public static bool isSuccess = false;

if (args.Length > 0)
{
    foreach (var m in args)
    {
            var argum = m.ToString();
            if (argum.Contains("-main"))
            {
                .....

                Console.WriteLine("Start");
                foreach (var a in Query.WorkItem)
                {
                    workitemList.Add(a.id);
                }
                Info(xml, workitemList, RestAPI);
                Console.WriteLine("Complete");
                isSuccess = true;
            }
            else if (argum.Contains("-sub"))
            {
                .....
                //run complete
                isSuccess = true;
            }
    }
}
else
{
    return;
}
Posted
Updated 13-Jun-22 23:39pm
v2

1 solution

The "official" way would be Using Application Settings and User Settings[^]
Example for a user setting:
Properties.Settings.Default.isSuccess = true;
Properties.Settings.Default.Save();
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900