I have a WCF service, it response with JSON. I need to create a language file, which I can edit on production server. no problem if I will need to recycle App pool.
I was about to use Resource file, but I was worry that it is not editable by end user.
I don't need to edit it pragmatically, the end user will edit it by opening the file in notepad without recompiling the application.
What do you suggest?
Yes you can using the ResXResourceWriter class.
If you need to generate the Designer.cs file as well see this question Programmatically generate Designer.cs for resx file (ResXResourceWriter/ResXResourceReader)
If you need to modify the existing resx files see this question Modifying .resx file in c#
According to MSDN, you can add new resource at runtime:
You can incrementally add resources for new cultures after you have
deployed an application. Because subsequent development of
culture-specific resources can require a significant amount of time,
this allows you to release your main application first, and deliver
culture-specific resources at a later date.
http://msdn.microsoft.com/en-us/library/sb6a8618%28v=vs.110%29.aspx
I think editing current resource will also work.
Your users should be able to edit the files with no problems, the resource files are XML files that can be opened in notepad or any text editor, they could even open it in Excel and get multiple columns that they can easily edit.
This will require recycling your App pool but you're open to that.
[edit]
You don't need to be recompile as I mentioned before if your resource files are marked as content, but your App pool will be recycled to pick up changes
I am not sure but it seems that user can't edit resource file using a notepad at runtime, and the application should rebuild in order changes takes effect.
Setting file with user scope can do the job.
Related
I have a WCF service that I am writing and part of it requires reading a text file and updating the contents.
The structure of the project is:
WCFServiceProj
AddressLayerFolder
text file
class with code to access file
Currently when I publish it adds a new version of the text file to the publish folder, which I can read and update, however the original file in the solution does not get updated so whenever I republish the file is out of date.
How can I get the original file updated so that publishing will not cause an issue?
Probably the simplest answer is to not overwrite the actual file when publishing by changing its BuildAction to 'None'. If you need the live copy of the text file then manually bring this down.
A word of caution: you shouldn't really be mixing your development and production environments in this way by having live data for development. Of course, a slightly different approach is that if you're storing volatile data - is a text file the right mechanism to persist your data? 99 times out of a 100, it isn't.
I am working on one desktop application which is built by using .net WPF. I have some data inside the application like images,videos..
I want to make this folder secure, so nobody can access the data inside the folder after application installation. Only the application can read the data from that directory.
Even though administrator of that machine can not open that folder to check the content.
Is it possible to have this kind of security inside the WPF application.
Only motive it to keep the sensitive data protected from external copy from the application users.
Thanks,
Vijay
It depends on how you use the resources.
Actually you could encrypt all "protected" files, so that after the installation every one can copy but no one can use them unless your application decrypts the files.
When you encrypt files you should definitively test the performance (decryption takes some time).
Two links showing how you could do it:
What's the easiest way to encrypt a file in c#?
http://lukhezo.com/2011/11/06/encrypting-files-in-net-using-the-advanced-encryption-standard-aes/
Add the file you would like to strongly protect to you solution. Then right click each file, go to properties and set its "build action" to "embedded resource".
And for how to access the resource stream from within the exe for use with in your application, see link below
How to compile all files to one exe?
That way, your private files will not be copied to the installation folder but will instead reside inside your .exe file.
WPF is beside the point. Applications run with the permissions of the users that start them. If an application needs access to files, then the user will also need rights to those files.
In short, the answer is no, you cannot do exactly what you are asking.
The best you will be able to do is make it hard for a user to discover where the assets are coming from, but you will never be able to give access to your application without giving access to the application's user.
I am currently developing a ClickOnce application that converts CSV files for a database update. The program requires the user to have the ability to change the configuration files for a database change, and change an XML file which populates a drop-down list in the app.
Now I understand that the files are kept in the user/appdata folder to ensure there have the correct privileges, but do I have any influence as to what those folders are called, or where they are saved?
By default, the files are saved in AppData\Local\Apps\2.0\LD7ZEJK0.7AE\NJ42PEPW.1QX\csvt...exe_169e1a4011fbe7ec_0001.0000_none_04507fe9e077ae84
Can I change that to say Documents\CSV_Files or something similar? And if I do, how would I reference the XML file in the configuration file so the program knows where it is?
Normally, you shouldn't have to care about the location yourself. Just mark your XML file as data in the ClickOnce manifest and access it using the well-known:
ApplicationDeployment.CurrentDeployment.DataDirectory
Here's an MSDN article describing it: Accessing Local and Remote Data in ClickOnce Applications
I would never store any data that is important to be retained in the case of an update in the actual ClickOnce deployment directories -- it is too dangerous. You should copy those files out to ApplicationData and access them there. This article shows you how to do that.
I have an app that has search functionality. The search algorithm is compiled to a separate dll. In the C# code for the search algorithm, I am using strings held in a settings file to point to the directory where the search index resides. But once the search code is compiled, the settings file is somehow incorporated in the dll. I want to have multiple versions of this code running on my server with each pointing to a different location for the index. And I want the operator to change a file to have each version point to something else as they find necessary. Both config files and settings files end up getting incorporated in the dll. How do I then accomplish this? What is the right industry standard way of doing this?
It's strange that the settings file is compiled... are you sure about that? Setting, config and resx files should be copied to the output directory, it's even a property you can modify on solution explorer. Then you should get it's values by doing
System.Configuration.ConfigurationManager.AppSettings.Get("YourKey")
But I think this won't know about user changes until app is restarted. If you want settings to be dynamic you should either store them on a database, or on a file that you open, read and close every time you need it.
Hope this helped!
i have an windows application that i have made by visual studio 2008.this application uses some graphical files such as jpeg.i make a setup for this appreciation but i worry about such files being modified by client.would you please help me how to protect those files ?
To detect such a tampering you should add your graphical files as resource within your application (or load from another assembly) and use Strong-Name signing. Even if it is not completely secure, it should prevent the most ones from altering your resource files.
You could embed the images into resource files that get included in the exe.
The easiest way is to use the images as a resource.
If you don't want to do that for any reason, then you could also calculate a cypher of the jpegs (maybe MD5) and check them against the one you previously stored in the code while loading the load program (form.load or whatever).
You could sign your files this way no one would be able to change the files without having your certificate.
this might be overkill and it depends on how mutch security you want else just place the images as resources.