S
S
sashka_amelin322020-07-11 12:44:18
C++ / C#
sashka_amelin32, 2020-07-11 12:44:18

How to make an actual path to a document in C#?

class Program
    {

        static void Main()
        {
            string startPath = System.Reflection.Assembly.GetExecutingAssembly().Location;

            bool menu = true;
            do
            {
                Console.WriteLine("Меню: \n0) Закрыть программу \n1) Амелин А.Е. \n2) Климова М.А. \n3) Корнюхов Д.А. \n4) Новиков К.Ю. \n5) Тароло А.А.");
                int list = Convert.ToInt32(Console.ReadLine());
                switch (list)
                {
                    case 0:
                        return;
                    case 1:
                        do
                        {
                            Console.WriteLine("Индивидуальное меню Амелина А.Е. \n1) Реферат на тему /Инновация в образовании/ \n2) Презентация \n3) Перейти к основному меню ");
                            int list_amelin = Convert.ToInt32(Console.ReadLine());
                            switch (list_amelin)
                            {

                                case 1:
                                    string OutReport = startPath + @"\ПРАКТИКА АМЕЛИН АЕ\АМЕЛИН\Материалы\ПРАКТИКА2020.docx";
                                    Process.Start(@"C:\Program Files (x86)\Microsoft Office\Office16\WINWORD.EXE", OutReport);
                                    break;
                                case 2:
                                    string OutPresentation = @"C:\Users\Александр\Desktop\ПРАКТИКА\Материалы\АМЕЛИН\ПРАКТИКА2020.pptx";
                                    Process.Start(@"C:\Program Files (x86)\Microsoft Office\Office16\POWERPNT.EXE", OutPresentation);
                                    break;
                                case 3:
                                    Main();
                                    break;
                            }
                        }
                        while (menu);
                        break;


There is such a code.
The bottom line is that the menu could go to the "profile" of each student. And there will be his work. So the question is, how to make the actual path to the file so that the program can be run on any PC, and not just this one. Roughly speaking, it is necessary to do something so that it would be possible to run files from the main directory.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Korotenko, 2020-07-11
@firedragon

Personally, I did not understand anything.
Chew something like this
1. Displaying the student menu (some code looks for the base directory)
2. Going to the student / ku
3. Displaying the summary or presentation menu or exiting to the previous one
4. Launching the program by token

I
itgood, 2020-07-13
@itgood

in order to search through all directories on any PC, it is necessary that the name day of the file contains keywords, for example, Amelina A.E.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question