Reputation: 23
I have an app that needs a json file in the same directory, but the file is directly visible and accessible when anyone uses it,and editing it could break my app. How can i hide that file? Im looking for an archive or packaging method thay would still let me execute the exe.
Edit: A single file solution would be ideal, maybe an archive that executes my exe and stores the other file?
Upvotes: 0
Views: 596
Reputation: 160
If your aplication is very small and doesn't use certain frameworks you can delete the app.config file altogether.
See answer to this question
If you have a few variables in your config, you'll now have to make static class to define them at compile time.
class MySettings{
public const string Setting1="Value of setting 1";
public const string Setting2="Value of setting 2";
}
And in your code:
var setting = MySettings.Setting1;//then use your setting in your code
The idea of having a config file is so that you can make changes after the application has been deployed. For complex apps, you may have a different config file for each deployment environment (e.g. develeopment environment, test environment, live environment, etc)
Upvotes: 0
Reputation: 406
You can try hiding the file by using File.SetAttributes:
File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden);
Upvotes: 2