+ 1

Is this even possible?

Trying to currently make a program in C# which will grab all config files from a steam folder however there is no exact path to the directory as everyone who uses the program could have it: C: or D: etc. the only common thing is /steamapps/common/. Is there any way to do that without prompting the user to choose file location?

2nd Aug 2022, 1:22 AM
Kieboard
Kieboard - avatar
5 odpowiedzi
+ 3
You would use the Exists() method for File or Directory. e.g if (File.Exists("c:\Steam\steamapps\common\Rusts\cfg\config.cfg")) { // code for true }
2nd Aug 2022, 2:29 AM
Brandon
Brandon - avatar
+ 3
It is possible if you want to read from the registery, steam app configuration files, etc. Your simplest option would likely be to check if standard locations exist and prompt the user for a location if not found. There are examples of the harder way on Stack Exchange.
2nd Aug 2022, 2:14 AM
Brandon
Brandon - avatar
+ 2
You could skip the else clause entirely actually. cfgfilepath = "\default\path\to\file.cfg" if (File.Exists(cfgfilepath) == null) { // Prompt user for file path. }
2nd Aug 2022, 2:41 AM
Brandon
Brandon - avatar
0
Brandon How would i check if the standard location exist for example /Steam/steamapps/common/Rusts/cfg/config.cfg. Obviously using an if else statement there but what would be the code to check to see if it exists?
2nd Aug 2022, 2:17 AM
Kieboard
Kieboard - avatar
0
And then for the else just use a standard choose location window? :) also that is very helpful thank you!
2nd Aug 2022, 2:31 AM
Kieboard
Kieboard - avatar