This question already has answers here:
Why are persisted user settings not loaded?
(2 answers)
Closed 7 years ago.
I am working on a project and I need a kind of variable that save the value and after restarting the program, the value won't get refresh.
For example:
Home Page of a web browser that when you change it, it will save and after restarting the application, it won't reset to the first Home Page Address.
I thought that I can do it using application properties settings
Properties.Settings.Default.
But it didn't work.
If the setting is application wide, and not per user, you can use the AppConfig to store the value. A similiar question was asked here.
Sample code copied from Amol M Kulkarni:
Configuration config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
config.AppSettings.Settings.Add("YourKey", "YourValue");
config.Save(ConfigurationSaveMode.Minimal);
Related
This question already has answers here:
Check if an executable exists in the Windows path
(8 answers)
Closed 3 years ago.
I am working on a WPF app, and I would like to include a button that directs it to another app. I would like it to have the following functionality:
If the app is installed on the user's computer, it opens the app for them.
If the app is not yet installed, it sends them to a link where they can download the app.
I know I will need to use Process.Start to open the app, but I am stuck on how to check if the app exists. If anyone could point me in the right direction it would be appreciated!
Two things you can use:
File.Exists(string) - Checks if the file exists.
try-catch - Simply try to open it, and handle any exceptions.
I would probably opt for the first solution...
This question already has answers here:
How can I remove the ASP.NET Session ID from my URL?
(2 answers)
Closed 6 years ago.
I've recently developed a web a pplication. Specifics arent necessary. My issue is that whenever i start up my project, it generates a random code sequence, just before the name of my page.
http://localhost:53655/_Beta_Webiste/(S(sbjvzcdbbugovmuzvdt25scm))/administrator.aspx
As you can see, it is this random piece here
(S(sbjvzcdbbugovmuzvdt25scm))
Now it always starts with an (S("Random code here")). Always starts with an S. Does anyone know what the issue is here, as it can lead to confusion with the customers. Also please not that if i even just type
http://localhost:53655/_Beta_Webiste/administrator.aspx
It will still generate that code. (It does this for all links, even when i hover over my Href's. Help is greatly appreciated.
It is not an issue.
Your website using "Cookieless" environment (specified in web.config).
You can find <sessionState cookieless="true" /> in your web.config file. Just make it false or remove completely (default value is false).
You can get more details about it from here.
This question already has answers here:
Where does Windows store its "Open With" settings?
(3 answers)
Closed 9 years ago.
I have a little bit confusing problem. I'm not a beginner but I don't know how to do it..
For example I've written a program like notepad from which you can open files, save and etc. But when I set any custom format like ".blabla" to be opened by my app it is not working, so how can I make it to be opened by my app?
It is in WinForms
You need an entry in the registry for custom file extensions. You can try inserting a key in the registry as follows:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\
This question already has answers here:
Changing App.config at Runtime
(4 answers)
Closed 9 years ago.
So I was looking at the solution here to figure out how to do it. And, it works for when I run my project multiple times. However, from my understanding, the save only occurs when the project closes. What I would like to do is to save it when I need to during my code, so that during the same run time, I can accessed the previously saved files. Does anybody know how to approach this problem?
This is what I'm using to save my app settings at run time:
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["CurrentPromoId"].Value = promo_id.ToString();
config.AppSettings.Settings["Date"].Value = DateTime.Today.ToString("yyyyMMdd");
config.Save(ConfigurationSaveMode.Modified, true);
What about RefreshSection?
ConfigurationManager.RefreshSection("appSettings");
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
setting UAC settings of a file in C#
I want to set file permissions so only those with administrative privileges can change it.
Can anyone give me a good example on how to do this in c#?
UPDATE
I've tried various things with FileSecurity, and I simply can't get a hang of it.
Here are the permissions that I'd like to impose on file:
Administrators can access anything (doesn't matter privileges, so the problem will be other users. The fourth argument of System.Io.File.Create. is an System.Security.AccessControl.FileSecurity object. That's what you need.