Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In my project one of the scenario I would like to store XML File to Registry. Also need to get read XML File from Registry. Can anyone please help me!!!

What I have tried:

I have stored local temp folder in C drive. But sometimes it wont access to create. So I decided to store it in Registry.
Posted
Updated 5-Nov-19 23:16pm

You should not. Windows registry is not meant to become a file repository. Stuffing huge data contents in there will have a terrible impact on the performance of the system.
You might consider the proper solution instead: using a folder in application data folder (or local application data folder) of logged in user.
Something like:
C#
using System;
using System.IO;
using System.Reflection;

// For roaming user's application data folder
string path = Path.Combine
(
   Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
   Assembly.GetExecutingAssembly().GetName().Name,
   "temp"
);

// OR

// For local user's application data folder
string path = Path.Combine
(
   Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
   Assembly.GetExecutingAssembly().GetName().Name,
   "temp"
);
 
Share this answer
 
Comments
vasanthkumarmk 6-Nov-19 3:49am    
Thanks for your answer, but instead of storing local folder I would need to store common place like Registry.
phil.o 6-Nov-19 4:04am    
Like I said, you are attempting to use the registry for something which it has not been designed for. This is a terrible idea. Besides, there exists an application data folder for all users of the computer; this is the common place you are searching for.
vasanthkumarmk 6-Nov-19 4:17am    
If so shall I convert XML data to binaries and store it in Regx file? Will it good idea? Your suggestions please.
phil.o 6-Nov-19 4:36am    
What is a Regx file? And why converting XML data to binary? Isn't it just enough to store a plain old xml file where all configuration files should normally go?
Remember that I do not know anything of your real requirements. 'Storing something in the registry' is not a requirement per se, it is the solution, which you have imagined, to an issue which I am not aware of.
vasanthkumarmk 6-Nov-19 6:21am    
Thanks!!!!
I already gave you a link to an article which explains where you should store your data. Do not use the registry, it can do untold damage to your system.

And please do not post the same question in multiple places.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900