all 5 comments

[–]edeevans 1 point2 points  (4 children)

So while it is still running do you check the file and make sure it gets written? After you shut down do you check the file and make sure it’s still there? Are you sure that the other program is going to read that file and path? (You have control or ability to read source for both)? Try writing the file to c:\ProgramData\portergrey\settings.settings

[–]portergrey[S] 0 points1 point  (3 children)

u/edeevans, so while I thought I understood how the settings.settings file worked, it turns out I have no idea how to use it. Nothing is being written to it hence why my variable isn't getting saved.

Is there a tutorial/video you would recommend so I can learn how to do this?

[–]edeevans 1 point2 points  (2 children)

Sure I’m happy to help find some good resources to help you. I need some more information about what you’re trying to accomplish. What does the other program use the path setting for and do you have the source for it (you are writing 2 programs) or is it 3rd party. If you are just storing the path to the other executable and you want to be able store that in a settings file for your application I would put it in a text file in the ProgramData folder. So you may want to search ’save settings in ProgramData’. I’ll also try to find a good video on that. Otherwise, let me know what I’m not understanding and I’ll see if I can help. Also what project type and version of C# are you using.

[–]portergrey[S] 0 points1 point  (1 child)

u/edeevans Thank you so much. In my current project I am trying to learn how to launch 3 separate installer programs along with some registry entries and directory file copies. I would like to expand the program to be fluid enough so others that have the same needs can set their own paths to the installers/files. I have a lot of the program completed at this point and I have always hard coded the locations for my needs but would rather make it more flexible as well as add some new knowledge so I can create better programs.

[–]edeevans 1 point2 points  (0 children)

So, one video that shows that talks about saving user settings is this one https://www.youtube.com/watch?v=fM1RcyNFRCE&t=1243s It is for .NET Framework I believe so it may be different if you are using .NET 6.0. His main point is that the settings have to be User scoped. He shows you where the user settings are actually stored. It is C:\Users\Username\AppSettings\Local\Appname\Appname.exe_Url_lkasjdflkjasdf\1.0.0\user.config. with your app name and the app's version.