同步写入文件 [英] Synchronous writes to a file

查看:38
本文介绍了同步写入文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的asp.net应用程序,带有一个简单的表单和两个文本框。


当用户填写文本框并发布时,我将其保存为XML文件。 br />
我最终会有多个用户试图以相同的时间保存

时间。

我是否需要任何保护代码来实现这一关键部分?


我正在看锁定声明,但我不认为它符合我的需要。


-

Erick Sasse

解决方案

为什么不使用显而易见的 - 数据库?



Erick Sasse < ES *********** @ nospam.yahoo.com.br>在留言中写道

新闻:%2 *************** @ TK2MSFTNGP12.phx.gbl ...

我有一个非常简单的asp.net应用程序,带有一个简单的表单和两个文本框。

当用户填写文本框并发布时,我将其保存为XML文件。
我最终会有更多而不是一个用户试图在同一时间保存。
我是否需要这个关键部分的保护代码?

我在看锁定声明,但我不是认为它符合我的需要。

-
Erick Sasse



Frankie写道:
< blockquote class =post_quotes>为什么不使用明显的 - 一个数据库?




为什么显而易见?数据库不是每个问题的解决方案。


-

Erick Sasse




" Erick Sasse" < ES *********** @ nospam.yahoo.com.br>在消息中写道

news:eR ************** @ TK2MSFTNGP15.phx.gbl ...

Frankie写道:

为什么不使用明显的 - 一个数据库?



为什么显而易见?数据库不是解决每个问题的解决方案。

-




IMO数据库是解决此问题的正确方法。


XML不是每个问题的解决方案......


对话听起来像这样:


Erick:我用锤子敲打这个螺丝有困难


Frankie:使用螺丝刀


Erick :不,我想用锤子 - 但它不能正常工作......


I have a very simples asp.net app with a simples form and two textboxes.

When the user fills the textbox and post, I save it to a XML file.
I''ll have eventually more than one user trying to save at the same
time.
Do I need any protection code for this critical section?

I was looking at lock statement, but I don''t think it fits my need.

--
Erick Sasse

解决方案

Why not use the obvious - a database?


"Erick Sasse" <es***********@nospam.yahoo.com.br> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...

I have a very simples asp.net app with a simples form and two textboxes.

When the user fills the textbox and post, I save it to a XML file.
I''ll have eventually more than one user trying to save at the same
time.
Do I need any protection code for this critical section?

I was looking at lock statement, but I don''t think it fits my need.

--
Erick Sasse



Frankie wrote:

Why not use the obvious - a database?



Why obvious? Database is not a solution for every problem.

--
Erick Sasse



"Erick Sasse" <es***********@nospam.yahoo.com.br> wrote in message
news:eR**************@TK2MSFTNGP15.phx.gbl...

Frankie wrote:

Why not use the obvious - a database?



Why obvious? Database is not a solution for every problem.

--



IMO a database is the right solution for this problem.

XML is not a solution for every problem either....

The conversation sounded like this:

Erick: "I am having trouble pounding in this screw with a hammer"

Frankie: "Use a screwdriver"

Erick: "No, I want to use a hammer - but it is not working right..."


这篇关于同步写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆