Where to put files used by a .Net application [closed] - c#

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
Here is a question not about code but about patterns. I'm developing a .Net application that needs to use three files in order to work properly.
File 1: Has the app settings created by a configuration form
File 2: Binary file that contains a set of serialized objects used as a playbook that the application follows in order to realize sequential tasks.
File 3: A sqlite database used as a record cache that the application updates on every start
Now my question is about file location, where to put this files? On Program Files or AppData inside the users's Documents And Settings.
Thanks in advance.

AppData should always be preferred, since it requires less permissions (you might need Administrator permissions to create / updated files in Program Files).
Also it depends whether data should be personalized or global for all users. Take a look at this post

Related

Is there any way to Read & Update appSettings.json file from any controller method to save usersettings in ASP.NET Core 2 MVC [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I tried many tricks from StackOverflow to Save & Update appSettings.json file but nothing working. Some snippets working only in Startup.cs only for read appSettings.json not for updating. Please help!
First of all, it's a bad idea to persist user settings into appsettings.json. The OS process executing your MVC app should never have write permission to this file for security reasons.
I would probably use a DB engine with ACID capabilities for this purpose. However, it could be ok to store such user settings in the file system - but in a separate file, at a safe location.
For example I'd create a folder named say App_Data in the application root folder, set write permission to it and place an adminsettings.json file into it. Then I'd use this file as my persistent storage for the said user settings.
Obviously, it would require some coding to make all this work. I put together a code sample for you which aims to reuse the configuration and options API of .NET Core. I think it exceeds the size acceptable here, so I made it available as a Gist.

Add news to c# application [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
We have a c# application wich is used by user to do stuff ;-)
What I want is to add at the startpage of the application some news or information like "hey, there is a new update for the application" or "did you know this feature..." Basically I want something similar like the startpage in Visual Studio.
The news should remain when there is no internet connection and update when there are new entires.
What's the best way to do this?
Thanks
Let your application read some data from file located in the server (XML is good idea), Also you must save the current version of your app in some file (or some where).
So after comparing between the two values you can decide what to show in your news bar.
To show some news you can just read it from another XML file in the server, Then organized it like you want.
here is good ways to read XML from server Read an XML file from http address

Set delete time upon file creation [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm working on an application where I video record the screen of the script running. I use SharpAvi for recording the screen and I would like to set a time for deleting the file. The only way I found is to run a batch that looks for files older than 7 days or so. I would like to have to set the delete time upon creation. I'm not sure if there is a way to do that or even of Windows support this kind of file creation.
Rather than using a batch file, create a RemoveOldRecordings method in your application that is called when your application is started. Use the GetFiles to read your "recording" directory, deleting "recording" files with LastWriteTime more than 7 days ago.
If you allow the users to save the recordings to different locations, though, you should not automatically delete files without their confirmation.
Also, while testing, rather than delete files, just output the filenames you've identified for delete to log or console window until you're sure you're handling that correctly.

How to avoid ASP.NET website being hacked? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
AFAIK attackers can overwrite files which have CHMOD values 777 on linux servers. Today my web site which created by myself using ASP.NET has been hacked. My Site.master page has been appended with lots of backlinks and there was a folder named as Sayers which has many html files (probably include search keys).
I could easily delete the folder and restore the original Site.master file.
I do not have SQL injection problem. Even if so I would have seen some additions or changes in the records. There is nothing. There are only changed files and added folder.
I have updated my FTP password. I am 100% sure that I do not use a third party extension. All the code is handmade (: So I want to know how to prevent this to be done again. Also what could be the vulnerability about the website. I also want to know if it is a server side problem or my problem.
I am using a hosting company's service. I use FTP (21), not secure.

Moving files from PC to MAC [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to ask how can I copy files from PC to MAC using C#. Also my application will create new folder when needed and copy / move files in them
By which technology you want to move files ?
1- Over the network ? using Directory access protocols ?
2- Through Web ?
Each has different aspects. as for network you just need to have access to mac on windows computer and tell them path. using **SYSTEM.IO** name space you can easily copy files from one directory[Windows] to other[MAC] using their path. Window will take care of permissions but be sure the user which you are using to access has write permission to folder where you are copying files.
Through web you might need to implement web programming to read and write each file you post.

Categories