saustee
saustee

Reputation: 3

How to get the users certain directory for apps

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");
        }

Upvotes: 0

Views: 64

Answers (2)

Matthew Ransley
Matthew Ransley

Reputation: 104

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");

Upvotes: 1

SzybkiDanny
SzybkiDanny

Reputation: 263

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

Upvotes: 0

Related Questions