Briefly about working with files. Consider a primitive console application:
using System; using System.IO; namespace playground { class Program { //Допустим, категория просто определяется цифрой (1 - Повар первой категории, и т.п.)? //которую мы для простоты будем хранить в виде строки (т.е. в текстовом виде) public static string Category; static void Main(string[] args) { //Если файла с настройками нет - условно, первый запуск приложения if (!File.Exists("settings.txt")) { // Console.Write("Укажите категорию повара: "); //Пользователь вводит цифру, обозначающую категорию Category = Console.ReadLine(); //...И, собственно, сохраняем её в файл File.WriteAllText("settings.txt", Category); } //Файл с настройками найден, читаем из него данные else { Category = File.ReadAllText("settings.txt"); } //После того, как пользователь указал категорию (если это первый запуск), или программа считала её из файла (если не первый), выведем информацию в консоль: Console.WriteLine($"Повар {Category} категории"); Console.ReadKey(); } } }
String using System.IO; Mandatory, it lets you say, gives you access to the methods of working with files (among other things).
Next, pay attention to if (!File.Exists("settings.txt")) - here we check for the presence of the file "settings.txt". In general, the full path to the file is passed as an argument (you can use environment variables ), in this case it checks for the presence of a file next to the program (in the same folder).
If the file is not found, the user is prompted to enter a number: Category = Console.ReadLine(); Which is immediately written to the file: `File.WriteAllText (" settings.txt ", Category);
If the file already exists, the program simply reads the number from the file: Category = File.ReadAllText("settings.txt");
I repeat, this example is very primitive. Read the manual , you can, of course, write to the file much more complex structures than just the value of one variable.
In general, as already noted in the comments, there is a huge variety of ways to store program data, just writing to a file is far from the only one.