Storing data in Windows App - c#

I have made a Windows App which is a spelling game, the user has a score, for example if a user gains a score of 180 when they close the app and reopen the app the score is not there anymore. Can people please give me methods of resolving this so it stores everything about the user (score and name) in which they can later access it if they close the app.

The Windows Store API provides a way to write your own local data to the file system, as described here:
Accessing application data
You read and write to it just as if it were a normal file on your hard drive, you just have to use their API in order to get the file handle.
You could of course also use a web service and store the data in a database, but given your experience/app complexity, thats probably a path to take with a different applciation.

Related

Application permanently store variable value

I am using Properties.setting.default.var to permanently store a value in a C# application on the same PC.
Now I am facing a problem that when I save the value but copy the application to another PC, the permanent value does not remain. Does the properties.setting trick not work in this scenario? If yes? Please advise the solution.
You need to get the settings stored in location that is accessible by all devices you plan to run your program on.
You can either
make sure current location of the settings file is synchronized between all devices - this way you can keep your existing code. You can sync files via roaming profiles in Windows Domain, by letting some file share synchronization tool to sync that file - i.e. OneDrive, by just manually copy file or any other way you can find.
write settings file yourself to shared location which can be accessed by all devices - pretty much any service that allow to upload data would do. Some will allow authenticated access so you can limit settings to particular user (OneDrive, GoogleDrive,...), some some form of anonymous/semi-authenticated uploads (which make personalized settings a bit harder and make them public for all to see). You may still be able to use some of the existing code but likely getting your settings in JSON format and uploading would be easier.

Where is the standard place to leave a Json file for an app when working on a mobile app?

I am developing a mobile app to connect to a centralized web-server, this app use a login sistem to do that, and i like to save the credentials in a file inside the mobile phone so the user doesn't need to make manualy the log-in every single time is connecting to the app.
For your tranquility, yes, the conection is API REST, AND the credentials are going to be sended for every operation, BUT the data Receiver of the web-server is well controled in a security level.
then what i want it to save user login info (the user on the mobile app) localy in order to send the data every time it will be needed to be sended,
for that i think in save it to a JSON file in some folder, so...
the question is:
What folder that should it be?
I think i probably can make it anywhere, but if you provide the path where, by standard -or at least by good practice- must be store, then i pretty much take that like the answer of my question (specialy if do it there is safer than in any other place inside the mobile phone)
Idealy it must be a place where, when the app is uninstalled, the file also be removed.
Thanks in advance

Make a file read/write accessible only from within my application

I'm creating a new database application using C# and MS-Access, I want to make the database file ONLY accessible for (read/write) operations from within my application so that the user haven't the ability to open the file from outside the application but the application has the full access to the database file, Or may be a better way is to make this permission for the root folder of the database.
Someone may ask "Why don't you just set a password for the database?"
My reply is that I want the root folder completely inaccessible and therefore the user won't know the database type I'm using because I will change the file extension for it.
As far as I know that the Windows OS uses the NTFS permissions -Groups- to make a folder accessible only for a set of groups like (Trusted Installer, System, Users,...)
Can I Achieve my goal using NTFS Permissions, or may be there is a better way to handle this?
I added fixed length encrypted bytes to the start of file using low level file read write operations and my app upon execution removed the bytes and had given me the actual file and I blocked the starup menu and short cuts keys and context menus using windows api so only my app had access to it plus I enabled windows stuff upon app termination and encrypted database again so it was unreadable for another access enabled app.

Securely save default application settings in windows phone 8

I have some sensitive information like application_key and connection_string. They must be predefined for users who install the application. Is it possible to set them so that noone can disassemble XAP file to see the actual values (for example in windows we can encrypt configuration file sections)?
Im not talking about user-entered data that can be encrypted(http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh487164(v=vs.105).aspx), im talking about data, avaliable from application load; for example application_key that is needed to connect to some server and gain access to some actions; so that i don't want such things to be visible.
Update: think ive found the solution:
Obfuscation with Windows Phone 8 so that XAP from the store CANT be opened and thats it!
See the UPDATE. The XAP from the store, even downloaded, can not be opened, its obfuscated by default.

Use C# to save photos to directory that user has no access to

I'm working on a WPF application right now in C#, and I need to be able to save some images. These images need to be saved into a directory that the user that's currently logged in doesn't have access to without some administrative privileges (essentially, to control the security on what images are being saved to that directory).
How can I set up such security permissions? Is there some directory that I can add subdirectories to with these images inside?
Normally, I would try to post some code in example to what I have. I'm not entirely sure where to begin with this problem, though.
As Andrew already told in his comment you should really best start with a service. This will run under another account (normally System, but you can change this within the control panel). To start with this a service is in the first step nothing more than any other normal process. So to get a connection between the user application and the service you can use any inter-process communication as you like.
The only difference between a normal application and a service is that the service will be started and managed through the service manager and thous needs to derive from ServiceBase. Also maybe this Walkthrough might help you to start.
Default context for all non-user programs is system which it available to you via service programming and you are not familiar with it. A hack would be logging into another account (i.e administrator) and run the program in that context which is not possible on all windows versions and I believe doesn't worth the resources it cost and also is a security risk.
Another solution would be encrypt your application data and store it somewhere.

Categories

Resources