开发者

Is it okay to store user data in XML files?

开发者 https://www.devze.com 2022-12-29 11:43 出处:网络
I have an ap开发者_运维百科p that is being used by a few users (< 12 users). There are less than 2000 records so I decided to use an XML file and store the file under \\company\\product\\p.xml.

I have an ap开发者_运维百科p that is being used by a few users (< 12 users). There are less than 2000 records so I decided to use an XML file and store the file under \company\product\p.xml.

Is this okay or am I breaking some design guidelines without realizing it?

EnvironmentL .net/c#/winforms

Update: Only 1 user, 1 thread will be reading or updating at any given time.


With a file you need to make sure that no more than one threads/processes or other units of work will be writing to it concurrently or risk corruption.

SQLite might be a good solution if you require multiple concurrent writes.


If there are not much records to handle then its ok to use XML file, it might turn out to be portable as well.


Compact sql would do the job alot better. Even just use odbc and an access database. xml files are not really ment to be used as a database.


It's worth noting that there are some security implications for information that goes into XML files which are essentially clear text, and can be read by any text editor. Anything that violates privacy laws, such as social security numbers, should not be stored in an XML file. Passwords should not be stored in an XML file unencrypted.

This sounds obvious, but I know of at least one ASP.NET application at a job where I used to work where the design included a clear text password for an impersonation account...Stupid.


Your best bet is to use some form of abstraction between your data storage and your application ( like an ORM ). You don't have to bring in an entire MVC stack into you code, but try to throw something together yourself that fits your needs. Then you can switch your backend from an XML file to a what other people have suggested here

0

精彩评论

暂无评论...
验证码 换一张
取 消