So I went in to the project and right click > Add and created a new Config.settings file and Login.settings file.
I then added a couple of inputs in each of those settings files.
How do go about accessing the settings values in those settings files?
I tried Properties.Default... but then it seems to not recognize Properties class as it shows a curly red underline in its name.
Do I have to import some name space?
I then try adding a new file called "Setting.settings" file and its still the same. I clean and rebuilt my project too.
Try right clicking on .settings file and selecting run custom tool option.
Also, sometimes it helps when you manually remove bin and obj files from project. Finally, close the solution and open again.
For user overrides and how settings are working refer to microsoft docs: https://learn.microsoft.com/en-us/dotnet/framework/winforms/advanced/using-application-settings-and-user-settings
Related
Im currently trying to add 2 files to my project. One of them is a .ovpn (vpn Config file) and the other is a batch file.
Im trying to create a directory in my code and then add these files to that newly created directory so when the users first run's this application it creates the files needed to run the application.
Is there anyway of adding these files like a resource so I can just reference them easy?
Sorry if this is a really simple question. Just never done it before.
Thankyou in advance!
You can try to change properties of your files like:
You don't need to necessarily have them embedded in the executable to have them easily referenced.
Add a 'resources' type object to your project - call it Resources.res
Right click on your project, make a New Folder
Call it 'Resources' - add your resource files in here.
Double click on your Resources.res file
Click on the 'Add New Existing File'
Navigate to your file that is in the Resources directory and select it.
You should see your file showing up inside the resources viewer now.
When you are writing code, you can now reference your added files via:
Resources.<nameoffile>
If your file is a text file, you can do things like
string jsonRequest = Resources.RegistrationRequest;
This should automatically set the files to be embedded as well, so they should be accessible at run time.
I tried to move a project from one folder to another following Hans Passant's advice:
Remove the project from your solution by right-clicking it in the
Solution Explorer window and choosing Remove. Move the entire project
folder, including subdirectories wherever you want it to go. Add the
project back to your solution.
After doing it, suddenly, a "Settings.cs" file appears in the solution, even though there is already a "Settings.settings" file under "Properties":
Also, when entering "Settings.settings" and pressing F7 ("View Code"), "Settings.cs" is opened.
How to fix it?
This is correct. Settings.cs is what allows you to save/change settings in your application through your application itself, instead of manually prior to building/running the project. It is auto-generated by your Settings.settings file. There is nothing to fix.
Well, what I have done is deleting both "Settings.settings" and "Settings.cs". Then I created a new "Settings.settings" file, and the problem is solved: There is a "Settings.settings" file, but the "Settings.cs" file is hidden.
Noted that if you have any settings in the file, you should keep a backup to restore the settings later in the process.
I am adding two new strings to our resource.resx but these newly added resources(strings) are not reflecting into the auto-generated Designer.cs file. I have rebuilt the project and also tried clean+build the project but no luck!
I have other resource files to support various international languages where also i need to these two new string resources
Please suggest.
Make sure the Custom tool property for your resx file is set to ResXFileCodeGenerator or PublicResXFileCodeGenerator. The .Designer.cs file should be regenerated every time you modify the resx file; if it's not, you can force it by selecting Run custom tool in the context menu for the resx file.
Right click the resx file in solution explorer, select "Run custom tool".
This generated/added the code in the .designer.cs file for the new strings in the resource file for me.
When editing the resource file in Visual Studio, check the Access Modifier drop down is not set to No code generation.
If it is then select the appropriate option from the drop down - Public or Internal.
You just need to :
& then do :
Tada! You got your new Designer.cs !
In JetBrains Rider, I had to right-click the resx file and select "Generate resources"
I had the same issue when I renamed my [YOUR_RESOURCE].resx file into [YOUR_RESOURCE].en-US.resx. It seems [YOUR_RESOURCE].Designer.cs no longer auto generates any code after you renamed the default [YOUR_RESOURCE].resx format to something like [YOUR_RESOURCE].en-US.resx
I came across this solution and it worked fine for me.
Close the solution
Edit the project file LastGenOutput tag for the resource file
Open the solution again and try
If you're looking to automate this process you can use resgen
resgen c:\development\test\properties\resources.resx /str:csharp
Hei,
So we have a whole group of people working on the same project and every now and then some files show as hidden, you know the blank file icon like obj or bin.
See my font and texture? They should be normal.
So, I can see them in the folder but not in solution explorer without hitting the Show Hidden Files. I can also modify them but I would like them back.
I have been trying to see if there was a solution but all I get is blogs on how to show hidden files.
So I found this thread
Visual Studio 2012 and missing files
that seems to be giving the reason of my problem. People are not saving properly before pushing to github.
Now is there a solution to this?(apart from saving properly) Can I make all of those files become normal files?
Cheers
Simply right click the files/folders and include them to source control again.
This usually happens if people check in new files/folders but do NOT check in the updated project file, too. The project file contains a list of all files which should be included within the solution. If this runs out of sync, exactly this crap will happen... ;)
Simply instruct your folks to properly check-in. Or do code review on check-in and verify that the project/solution file(s) are also checked in.
They show up as hidden because they're not part of the project/solution, but they are on your file system.
You can right-click the files and click Include in Project
If this does not solve the issue after checking in. The project file is what is not properly getting checked in.
Probably the problem is that they are not pushing the project file (file with extension .csproj). It holds all references to files included on the project so it needs to be pushed when new files are added.
Let everyone know that they need to push this file in order to everyone to catch latest changes on project.
How can we add readme files in web installers created using visual studio.After installing the product,readme file's path should be shown in control panel.
You can easily add a readme by creating it and putting it in the applications contents by finding the text file within solutions explorer, right clicking and then going to properties.
In the properties change build action to content and I'm assuming you'd want copy if newer selected on copy to output folder
from here simply go into the file system of your Installer project, go to application folder then right click on a blank space in the applications folder panel, add, project output and finally content files
this will put your text file inside the folder where it is installed on your client machine, I'm presuming you've already made the text file, if not simply create one by right clicking your project, add item, general tab and then text file.
EDIT
thankyou for the reply,
Rigt click your project, then choose properties and select the application tab you can change all the information by clicking Assembly Information...
EDIT 2
Theres a microsoft application called bizTalk that will do most of it all for you, there's a link with more information here http://msdn.microsoft.com/en-us/library/aa561017.aspx
EDIT 3
The best I can do after a lot of searching is to give you a path that will open a folder for you to place your readme into?
If you want to do that and tinker to see whether this path can be edited, then inside the file system of the installer, right click and press add special folder, then Custom Folder, name it what you like, something like ReadMeFolder? then right click and go to its properties change the DefaultLocation to whatever you like, but give it a property of ARPREADME, from here as soon as you've built and installed it, the folder path for this will be under the "readme" tab in your add and remove programs, there will be a way to change this so that it can target a file, Again I'll do a little more searching to see if i can make it open the file instead of the containing folder
Also have a mess around with making folders properties being ARP.... because the ARP stands for add remove program and its here that you can make the folder to certain things to do with the control panels Add & remove programs.