将数据写入磁盘?! [英] Writing data to disk?!

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

问题描述

我想得到一些关于将数据存储到磁盘的问题的反馈,以及

存储它的位置。我从来没有参加过
编程的制作环境,所以你不得不忍受我......


我的问题是关于存储数据库中的数据。是的我明白你

可以链接到你的程序中的数据库并读写数据库

等等嗯,这都是找到和花花公子但是如果你写这个申请的那个人没有SQL / Access或其他一些数据库供你使用?b $ b提供商怎么办? Microsoft是否提供了一个类库来使磁盘/数据更加简单,而无需将单个数据写入

磁盘?我已经做了一些搜索MSDN在线文档

使用序列化,将代码标记为可序列化,然后将其写入

到磁盘...实际上让它发挥作用...但这是有效的还是MS

有另一种方式更简单?我想要一些反馈,如果有人有

时间......


谢谢,


克里斯


-

保护你的系统就像对抗疾病一样 - 只要你保证基本卫生,b $ b b你可能会好起来的,但是你永远不会无懈可击。


Steve Shah - Unix系统网络管理员

I''d like to get some feedback on the issue of storing data out to disk and
where to store it. I''ve never been in a production environment in
programming so you''ll have to bear with me...

My question is about storing data in a database. Yes I understand that you
can link to a database in your program and read and write to the database
etc etc. Well, that''s all find and dandy but what if the person you''re
writing the application for doesn''t have SQL/Access or some other database
provider to use? Does Microsoft provide a class library to make disk/data
storage simpler without having to write individual pieces of data out to
disk? I''ve done a bit of searching through the MSDN online documentation
using Serialization, marking code as serializable, and then writing it out
to disk...and actually got it to work...but is this efficient or does MS
have another way that''s simpler? I''d just like some feedback if anyone has
the time...

Thanks,

Chris

--
Securing your systems is much like fighting off disease -- as long as you
maintain basic hygiene, you''re likely to be okay, but you''ll never be
invulnerable.

Steve Shah - Unix Systems Network Administrator

推荐答案

使用System.IO命名空间并阅读

StreamReader,StreamWriter,BinaryReader和

BinaryWriter。


这些类使用起来非常简单,可以创建一些精心设计的基础设施来将数据写入磁盘

浪费时间。


例如,如果你想写一个文本文件:


使用(StreamWriter s = new StreamWriter(@" C:\ temp \test.txt",false))

{

s.WriteLine(FileContents);

s.Clos e();

}


您还可以使用

.WriteXml方法将您的DataSet吐出到xml。 />




您可以将数据存储在XmlDocument

中并使用其.Save方法将其写入磁盘。


如果

你不需要共享数据访问权限,你可以做各种各样的事情。

集中访问。


-

Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.eggheadcafe.com/forums/merit.asp


Chris Springer < CS ***** @ adelphia.net>在消息中写道

新闻:m7 ******************** @ adelphia.com ...
Use the System.IO namespace and read up on
StreamReader, StreamWriter, BinaryReader and
BinaryWriter.

These class are so simple to use that creating some
elaborate infrastructure to write data to disk would
be a waste of time.

for example, if you wanted to write a text file out:

using (StreamWriter s = new StreamWriter(@"C:\temp\test.txt",false))
{
s.WriteLine(FileContents);
s.Close();
}

you could also spit your DataSet out to xml with
the .WriteXml method.

Or

You could store your data in an XmlDocument
and use its .Save method to write it to disk.

There are all sorts of things you can do if
you don''t need shared access to data or
centralized access.

--
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.eggheadcafe.com/forums/merit.asp

"Chris Springer" <cs*****@adelphia.net> wrote in message
news:m7********************@adelphia.com...
我我希望得到一些关于将数据存储到磁盘和存储位置的问题的反馈。我从来没有在编程的生产环境中工作,所以你必须忍受我......

我的问题是关于将数据存储在数据库中。是的,我明白,你可以链接到你的程序中的数据库,读取和写入数据库等等。好吧,这都是找到和花花公子但如果这个人怎么样
您正在编写的应用程序没有SQL / Access或其他一些数据库提供程序可供使用吗? Microsoft是否提供了一个类库,使磁盘/数据存储更简单,而无需将单个数据写入磁盘?我已经使用序列化在MSDN在线
文档中进行了一些搜索,将代码标记为可序列化,然后将其写入磁盘......并实际让它工作......但是这有效还是MS有另一种方式更简单?如果有人有时间,我只想要一些反馈......

谢谢,

克里斯

- <保护你的系统就像对抗疾病一样 - 只要你保持基本卫生,你就可以没事,但你永远不会无懈可击。

Steve Shah - Unix系统网络管理员
I''d like to get some feedback on the issue of storing data out to disk and
where to store it. I''ve never been in a production environment in
programming so you''ll have to bear with me...

My question is about storing data in a database. Yes I understand that
you can link to a database in your program and read and write to the
database etc etc. Well, that''s all find and dandy but what if the person
you''re writing the application for doesn''t have SQL/Access or some other
database provider to use? Does Microsoft provide a class library to make
disk/data storage simpler without having to write individual pieces of
data out to disk? I''ve done a bit of searching through the MSDN online
documentation using Serialization, marking code as serializable, and then
writing it out to disk...and actually got it to work...but is this
efficient or does MS have another way that''s simpler? I''d just like some
feedback if anyone has the time...

Thanks,

Chris

--
Securing your systems is much like fighting off disease -- as long as you
maintain basic hygiene, you''re likely to be okay, but you''ll never be
invulnerable.

Steve Shah - Unix Systems Network Administrator



您真正需要问自己的是您或您的客户希望如何
store" data"以及数据究竟是什么?是。不同的格式(数据库,

平面文件等)与他们有亲和关系,他们需要在做出这个决定时考虑
。您不应该寻找简单

方式进行数据存储,而是寻找能够为您和/或客户提供所需资金的方法。


例如,在选择数据存储设计

时,您需要考虑一些问题/想法。


我的

多个用户是否要共享(更新,添加,删除等)数据?如果是这样,那么DB更好,因为它具有

锁定记录的概念。


数据是否非常简单?如果只保存配置信息,那么XML文件可能会工作。


是否会有这些文件的多个实例的概念(用户1,用户

2等)?也许平面文件对此更好。


多个用户只共享一个实例吗?也许一个DB

会更好。


如何升级数据?如何处理 -

文件/表的副本或其他一些方法。


您是否需要保留roseta stone? (又称关键)到一些家庭酿造的

文件格式?如果您不遵循某些

标准格式(数据库,xml等),这将是您需要的。你不想打开一个文件和

里面有一堆垃圾并且不知道它是什么对你来说是什么?


它是一堆小值或只有1或2个大/巨大值(例如

图像)?


您是否需要查询此数据以获取报告或什么?数据库对此非常好!


谁将负责备份数据?你的程序(可能是平的

文件更好)或者你的客户IT部门会处理这个(数据库

服务器可能更好)?这是一个非常重要的一个要记住,因为如果你的程序处理用户输入的数据,他们将需要备份,

,如果你可以推动关闭它们然后它就少了一点

让你担心系统何时崩溃!


至于你有什么选择这里有几个我能想到的。我确定

还有其他人。

- 数据库服务器(SQL Server,MySQL等)

- 数据库文件(访问,等等)

- XML

- INI文件

- 注册表

- 平面文本文件

- 平面二进制文件(自制文件)


所有归结为需求。无论是您的客户

强加给您,还是您的应用程序对您的客户施加的那些。

您无法支持每个应用程序中的所有内容......或者您可以吗? :-)


希望这会有所帮助!

" Chris Springer" < CS ***** @ adelphia.net>在消息中写道

新闻:m7 ******************** @ adelphia.com ...
What you really need to ask yourself is how you or your customer wants to
store "data" and what exactly the "data" is. Different formats (database,
flat file, etc) have pro''s and con''s with them and they need to be
considered when making this decision. You should not look for the "simple"
way to do data storage but instead look for the method that gives you and/or
your customer what is needed.

For instance here are some questions/thoughts for you to consider when
choosing a data storage design.

Is the data going to be shared (updated, added to, deleted from, etc) my
multiple users? If so then a DB is better because it has the notion of
locking records.

Is the data very simple? Maybe an XML file would work if it is only
configuration information being saved.

Will there be the notion of multiple instances of these files (user 1, user
2, etc.)? Maybe flat files would be better for this.

Will there be only 1 instance that is shared by multiple users? Maybe a DB
would be better.

How will the data be upgraded? How will this be handled - copies of
files/tables or some other method.

Will you need want to keep a "roseta stone" (aka key) to some home brewed
file format? This is something that you will need if you do not follow some
standard format (database, xml, etc). You dont want to open up a file and
have a bunch of garbage in it and have no clue what it is do you?

Is it a bunch of small values or only 1 or 2 large/huge values (such as an
image)?

Will you need to query this data for a report or something? Databases are
great for this!

Who will be responsible for backing up the data? Your program (maybe flat
files are better) or will your customers IT department handle this (database
server is better maybe)? This is a very important one to keep in mind since
if your program handles user entered data they will want a backup to be done
at some point and if you can push it off on them then it is one less thing
for you to worry about when the system crashes!

As for what options you have here are a few that I can think of. I am sure
there are others though.
- Database servers (SQL Server, MySQL, etc.)
- Database files (Access, etc.)
- XML
- INI files
- Registry
- Flat text files
- Flat binary files (home brewed files)

What is all comes down to is requirements. Either the ones your customer
imposes on you, or the ones that your application imposes on your customer.
You cannot support everything in every application... or can you? :-)

Hope this helps!
"Chris Springer" <cs*****@adelphia.net> wrote in message
news:m7********************@adelphia.com...
我我希望得到一些关于将数据存储到磁盘和存储位置的问题的反馈。我从来没有在编程的生产环境中工作,所以你必须忍受我......

我的问题是关于将数据存储在数据库中。是的,我明白,你可以链接到你的程序中的数据库,读取和写入数据库等等。好吧,这都是找到和花花公子但如果这个人怎么样
您正在编写的应用程序没有SQL / Access或其他一些数据库提供程序可供使用吗? Microsoft是否提供了一个类库,使磁盘/数据存储更简单,而无需将单个数据写入磁盘?我已经使用序列化在MSDN在线
文档中进行了一些搜索,将代码标记为可序列化,然后将其写入磁盘......并实际让它工作......但是这有效还是MS有另一种方式更简单?如果有人有时间,我只想要一些反馈......

谢谢,

克里斯

- <保护你的系统就像对抗疾病一样 - 只要你保持基本卫生,你就可以没事,但你永远不会无懈可击。

Steve Shah - Unix系统网络管理员
I''d like to get some feedback on the issue of storing data out to disk and
where to store it. I''ve never been in a production environment in
programming so you''ll have to bear with me...

My question is about storing data in a database. Yes I understand that
you can link to a database in your program and read and write to the
database etc etc. Well, that''s all find and dandy but what if the person
you''re writing the application for doesn''t have SQL/Access or some other
database provider to use? Does Microsoft provide a class library to make
disk/data storage simpler without having to write individual pieces of
data out to disk? I''ve done a bit of searching through the MSDN online
documentation using Serialization, marking code as serializable, and then
writing it out to disk...and actually got it to work...but is this
efficient or does MS have another way that''s simpler? I''d just like some
feedback if anyone has the time...

Thanks,

Chris

--
Securing your systems is much like fighting off disease -- as long as you
maintain basic hygiene, you''re likely to be okay, but you''ll never be
invulnerable.

Steve Shah - Unix Systems Network Administrator



我一直想做的是想出一个程序当地

教堂,有二手家具捐赠/再分配计划。他们想要一个小型的应用程序,可以取代他们目前的纸张系统,使其更具成本效益,更高效和更优惠。

总体而言是最新的。抛开他们的动机,我设计了整个

界面,得到了他们的认可,现在我正在将数据写入磁盘。我最初的想法是创建一个用于

存储记录的Access数据库文件,以便真正轻松地访问数据并搜索

功能。我的问题现在变成......我怎么在C#中这样做?如果

他们没有MS Access怎么办?我还可以让应用程序在他们的机器上创建一个

访问数据库吗?内置.NET框架类

处理Access数据库?我确实有一些方向,其中我b / b
正在前进,但我很难过如何动态创建Access文件

并获取数据往返那个文件。感谢你收到的回复我已经收到了b $ b ...我非常感谢你提供的其他任何意见。


Chris

-

保护你的系统就像对抗疾病一样 - 只要你保证基本的卫生,你可能会没事,但是你'永远不会是b / b
无懈可击。

Steve Shah - Unix系统网络管理员

" Me" < me@home.com>在消息中写道

新闻:Gc ******************** @ comcast.com ...
Well what I''ve been trying to do is come up with a program for a local
church that has a donation/redistribution program for used furniture. They
want a small application that can take the place of their current paper
system to make it more cost effective and a bit more efficient and
up-to-date overall. Setting their motives aside, I''ve designed the entire
interface, gotten their approval, and am now moving on to writing the data
out to disk. My original idea was to create an Access database file for
storage of records to make for really easy data access and searching
capabilities. My problem now becomes...how do I do this in C#? What if
they don''t have MS Access? Can I still have the application create an
access database on their machine? What built in .NET framework classes
handle working with Access databases? I did have some direction in which I
was heading but I''m stumped as to how to create the Access file on the fly
and get the data to and from that file. Thanks for the responses I''ve
received already...I do appreciate any other input that you have.

Chris
--
Securing your systems is much like fighting off disease -- as long as you
maintain basic hygiene, you''re likely to be okay, but you''ll never be
invulnerable.

Steve Shah - Unix Systems Network Administrator
"Me" <me@home.com> wrote in message
news:Gc********************@comcast.com...
什么你真的需要问问自己,你或你的客户想要如何存储数据。以及数据究竟是什么?是。不同的格式(数据库,平面文件等)与他们有所不同,并且在做出这个决定时需要考虑它们。你不应该寻找
简单的做数据存储的方法,而是寻找给你和/或你的客户提供所需要的方法。

例如,这里有一些问题/想法供你考虑选择数据存储设计。

我的多个用户是否要共享(更新,添加,删除等)数据?如果是这样,那么DB更好,因为它具有锁定记录的概念。

数据是否非常简单?如果只保存配置信息,也许XML文件会起作用。

这些文件的多个实例(用户1,用户2等)是否存在概念。)?也许平面文件会更好。

只有一个实例由多个用户共享?也许数据库会更好。

如何升级数据?如何处理 -
文件/表格的复制品或其他一些方法。

你需要保留一个roseta stone吗? (又称关键)一些家庭酿造的文件格式?如果你不遵循一些标准格式(数据库,xml等),这将是你需要的东西。你不想打开一个文件
并且里面有一堆垃圾并且不知道你是什么?

它是一堆小值还是只有1或2大/巨大的值(例如
图像)?

您是否需要查询此数据以获取报告或其他内容?数据库对此非常有用!

谁将负责备份数据?你的程序(可能是扁平的文件更好)或者你的客户IT部门会处理这个问题(数据库服务器可能更好)?这是一个非常重要的保持心态,因为如果你的程序处理用户输入的数据,他们将需要在某些时候完成备份,如果你可以将它推到它们上,那么它就是
至于你在这里有什么选择我能想到的是一些。我确定
还有其他的。
- 数据库服务器(SQL Server,MySQL等)
- 数据库文件(Access等)
- XML
- INI文件
- 注册表
- 平面文本文件
- 平面二进制文件(自制文件)

所有归结为要求。您的客户对您施加的那些,或您的应用对您的客户施加的那些。你不能支持每个应用程序中的所有内容......或者你可以吗? :-)

希望这会有所帮助!

" Chris Springer" < CS ***** @ adelphia.net>在消息中写道
新闻:m7 ******************** @ adelphia.com ...
What you really need to ask yourself is how you or your customer wants to
store "data" and what exactly the "data" is. Different formats (database,
flat file, etc) have pro''s and con''s with them and they need to be
considered when making this decision. You should not look for the
"simple" way to do data storage but instead look for the method that gives
you and/or your customer what is needed.

For instance here are some questions/thoughts for you to consider when
choosing a data storage design.

Is the data going to be shared (updated, added to, deleted from, etc) my
multiple users? If so then a DB is better because it has the notion of
locking records.

Is the data very simple? Maybe an XML file would work if it is only
configuration information being saved.

Will there be the notion of multiple instances of these files (user 1,
user 2, etc.)? Maybe flat files would be better for this.

Will there be only 1 instance that is shared by multiple users? Maybe a DB
would be better.

How will the data be upgraded? How will this be handled - copies of
files/tables or some other method.

Will you need want to keep a "roseta stone" (aka key) to some home brewed
file format? This is something that you will need if you do not follow
some standard format (database, xml, etc). You dont want to open up a file
and have a bunch of garbage in it and have no clue what it is do you?

Is it a bunch of small values or only 1 or 2 large/huge values (such as an
image)?

Will you need to query this data for a report or something? Databases are
great for this!

Who will be responsible for backing up the data? Your program (maybe flat
files are better) or will your customers IT department handle this
(database server is better maybe)? This is a very important one to keep in
mind since if your program handles user entered data they will want a
backup to be done at some point and if you can push it off on them then it
is one less thing for you to worry about when the system crashes!

As for what options you have here are a few that I can think of. I am sure
there are others though.
- Database servers (SQL Server, MySQL, etc.)
- Database files (Access, etc.)
- XML
- INI files
- Registry
- Flat text files
- Flat binary files (home brewed files)

What is all comes down to is requirements. Either the ones your customer
imposes on you, or the ones that your application imposes on your
customer. You cannot support everything in every application... or can
you? :-)

Hope this helps!
"Chris Springer" <cs*****@adelphia.net> wrote in message
news:m7********************@adelphia.com...
我想要获得一些关于将数据存储到磁盘的问题以及存储位置的反馈。我从来没有在编程的生产环境中工作,所以你必须忍受我......

我的问题是关于将数据存储在数据库中。是的,我明白,你可以链接到你的程序中的数据库,读取和写入数据库等等。好吧,这都是找到和花花公子但如果这个人怎么样
您正在编写的应用程序没有SQL / Access或其他一些数据库提供程序可供使用吗? Microsoft是否提供了一个类库,使磁盘/数据存储更简单,而无需将单个数据写入磁盘?我已经使用序列化在MSDN在线
文档中进行了一些搜索,将代码标记为可序列化,然后将其写入磁盘......并实际让它工作......但是这有效还是MS有另一种方式更简单?如果有人有时间,我只想要一些反馈......

谢谢,

克里斯

- <保护你的系统就像对抗疾病一样 - 只要你保持基本卫生,你就可以没事,但你永远不会无懈可击。

Steve Shah - Unix系统网络管理员
I''d like to get some feedback on the issue of storing data out to disk
and where to store it. I''ve never been in a production environment in
programming so you''ll have to bear with me...

My question is about storing data in a database. Yes I understand that
you can link to a database in your program and read and write to the
database etc etc. Well, that''s all find and dandy but what if the person
you''re writing the application for doesn''t have SQL/Access or some other
database provider to use? Does Microsoft provide a class library to make
disk/data storage simpler without having to write individual pieces of
data out to disk? I''ve done a bit of searching through the MSDN online
documentation using Serialization, marking code as serializable, and then
writing it out to disk...and actually got it to work...but is this
efficient or does MS have another way that''s simpler? I''d just like some
feedback if anyone has the time...

Thanks,

Chris

--
Securing your systems is much like fighting off disease -- as long as you
maintain basic hygiene, you''re likely to be okay, but you''ll never be
invulnerable.

Steve Shah - Unix Systems Network Administrator




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

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