C
C#12mo ago
xp4eternity

2 Questions

Hi, I need to ask 2 questions as i am new to C#. So im missing 2 tasks to deploy my first app. And ive been struggling to find help on Youtube for my concerns. My first question. how can i give a button 2 events. for example "If radioButton_1 is selected, process.start <File X>" "if radioButton_2 is selected, process.start <File Y>" how can i do that? My second question is how can i give a file directory template. in an example C:%filelocation%%filepath% something around those lines. Help Appreciated!
6 Replies
Angius
Angius12mo ago
1. Bind to the click event of the radio button and add whatever code you wish 2. Do you want to create a path dynamically, or get a "universal" path, for example to user desktop no matter who the user is?
xp4eternity
xp4eternityOP12mo ago
2. to user desktop
Angius
Angius12mo ago
Environment.GetFolderPath(EnvironmentFolders.SpecialFolder.Desktop) I believe https://learn.microsoft.com/en-us/dotnet/api/system.environment.specialfolder?view=net-8.0 https://learn.microsoft.com/en-us/dotnet/api/system.environment.getfolderpath?view=net-8.0 I was not correct in my beliefs there, fixed it
xp4eternity
xp4eternityOP12mo ago
is there a microsoft learn link for the first. i still dont get it. or an example.
Angius
Angius12mo ago
That is the link SpecialFolder is an enum It contains values like .Desktop Using the method from the second link, you can turn that into a path So Environment.GetFolderPath(EnvironmentFolders.Desktop) becomes C:/Users/zp4eternity/Desktop/ Then just use Path.Combine() to append more path segments if needed
xp4eternity
xp4eternityOP12mo ago
still struggling for the bind to the....
Want results from more Discord servers?
Add your server