Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
Hey Guys,
I am trying to create app so I can run application from local user
and it is not reacting on Click
what I am doing wrong?
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

If this is getting me to the Roaming folder and I just need Appdata folder what then
this is my full path
C:\Users\Local User\AppData\Local\App folder\app folder\app.exe


What I have tried:

C#
private void Button11_Click(object sender, EventArgs e)
        {
            string some = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string el = "..Local\App folder\app folder\app.exe";
            string path = Path.GetFullPath(Path.Combine(some,el));

        }
Posted
Updated 28-Aug-19 23:57pm
v5
Comments
Maciej Los 29-Aug-19 5:36am    
Well, if you think that creating 3 string variables may cause any reaction, you're wrong.

Please, read my comment to the question first.

To run application (executable), you may use Process.Start Method (System.Diagnostics) | Microsoft Docs[^]
 
Share this answer
 
v2
First off, you need a backslash between ".." and "local", and you need to disable string escaping to ghet teh backslashes in there at all:
string el = @"..\Local\App folder\app folder\app.exe";


Then you need to use the Process class:
C#
Process.Start(path);

But you'd be better off using the SpecialFolder.LocalApplicationData enum value instead:
C#
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
 
Share this answer
 
v2
Comments
Kleo Rogers 29-Aug-19 5:54am    
C:\Users\WIN10\AppData\Local\App folder\spp folder\app.exe
This is Full path so I don't need roaming folder
OriginalGriff 29-Aug-19 6:07am    
Precisely: so use LocalApplicationData enum value instead.

But if you use ApplicationData you get "Roaming" added for you, and that's what the "..\local" bit of your next string was meant to remove. ".." is a "special directory code" meaning "directory above this one" - but only when it is not part of a directory name as in your code.
Kleo Rogers 29-Aug-19 6:16am    
Thank you very Much
OriginalGriff 29-Aug-19 7:08am    
You're welcome!
Here is the explanation for your code that you've posted
Now I don't know what are you expecting it to do ??

C#
string some = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

// some will give you C:\Users\YourUser\AppData\Roaming

string el = "..Local\App folder\app folder\app.exe";

// el is a string variable with some path with compile error as it should be \\

string path = Path.GetFullPath(Path.Combine(some,el));

// path will have C:\Users\YourUser\AppData\Roaming\..Local\App folder\app folder\app.exe


You should be more clear and improve your question
 
Share this answer
 
Comments
Kleo Rogers 29-Aug-19 5:47am    
C:\Users\WIN10\AppData\Local\App folder\spp folder\app.exe
This is Full path so I don't need roaming folder
dnxit 29-Aug-19 5:57am    
yeah then you can
Process.Start("C:\\Users\\WIN10\\AppData\\Local\\App folder\\spp folder\\app.exe");

try to run your app which is trying to open this app.exe as Administrator there might be permissions issue
Kleo Rogers 29-Aug-19 5:58am    
Yes but WIN 10 user will not bee on another computer
dnxit 29-Aug-19 6:04am    
then make sure you're logged in with WIN10 user :)

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