0

I am trying to make it so it finds the current user on the pc so that when i put (for example USERPROFILE) it can find the right directory to the exe

        private void siticoneImageButton3_Click_1(object sender, EventArgs e)
        {
           Process.Start("C:\\Users\\USERPROFILE\\AppData\\Local\\Programs\\lunarclient\\Lunar Client.exe");
        }
MikeJ
  • 1,154
  • 6
  • 9
saustee
  • 3
  • 2

2 Answers2

1

You should be able to use the Environment.UserName property like so:

Process.Start($"C:\\Users\\{Environment.UserName}\\AppData\\Local\\Programs\\lunarclient\\Lunar Client.exe");
0

You could try using Environment.UserName or Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) to get the path to (...)\AppData\Local directory.

SzybkiDanny
  • 182
  • 8