格尔,我找不到答案! [英] Grr, I can't find the answer!

查看:70
本文介绍了格尔,我找不到答案!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,


我一直在这里读新闻组已经有一段时间了,并且通过我这本非常有用的书去了

,Microsoft Visual Basic .NET Step by

Step Version 2003,一遍又一遍,我觉得这样的假人。我读过你了

fella'一边谈论溪流而另一边谈论溪流,而且不能为了b / b
我的生活能够很好地掌握它们。我一直在阅读你们彼此折腾的文章,但我不能完全跟随他们知道为什么

以及我怎么想的使用流而不是FileGet和FilePut

过去对我有用的东西。


我的困境是我一直在使用FileGet和FilePut我记得很长的例行程序,而且我不知道如何更有效地使用

的东西虽然我已经读到了这么多的流是如此之多比旧的

例程更快。我有一个小文件我正在使用该商店名称和

地址并定期搜索,但FileGet和FilePut

似乎只是如此这些天爸爸抨击很慢,即使在快速机器上也是如此。我知道这些机器应该能够在更短的时间内搜索整个文件

而不是我想到它,但是需要花一点时间,

大大减慢了程序的速度,因此必须有更好的方法。


我一直在使用的微软书中说流很棒,而且

甚至给出了一个使用它们的例子。我的问题是我不能用b $ b来弄清楚如何使用它们代替随机访问文件例程

FileGet和FilePut。我之前试图解决这个问题,并且在序列化的过程中发送了

。所以,我终于有了这个为我工作

今天,我非常高兴。我找到的所有信息

然而,并没有帮助我学习如何打开文件流然后

发送或检索记录后的记录往返,或者只是选择我想要的任何

记录,比如我可以使用随机访问文件和

FilePut和FileGet函数。


我很抱歉已经过时了,但是如果有人能指出我要找到如何做多个记录而不是单个记录,我会

非常棒。


这里有一个非常简单的例子,说明了我已经设法把它们整合在一起了

我遇到的所有信息:


< Serializable()>公共类blankRecord

< VBFixedString(24)>公共名称

< VBFixedString(32)>公共地址线路1

< VBFixedString(32)>公共地址线2

< VBFixedString(32)>公共地址线3

结束等级


私有子保存地址

昏暗记录为新的blankRecord

Dim fs作为New FileStream(" c:\test.txt",FileMode.OpenOrCreate)

Dim bf as New

Runtime.Serialization.Formatters.Binary.BinaryForm atter

bf.Serialize(fs,record)

fs.Close()

End Sub


我不明白的是我如何修改上面的代码让我

将多个地址保存到我的地址文件中,就像我可以的那样

使用:


FilePut(fileNumber,record,recordNumber)


非常感谢您花时间阅读我的长篇文章。


困惑的程序员,

Brian


PS也许如果有人知道一本书或文章的行为文件

Streams for Dummy,我会非常感激,因为我不想让任何人

觉得他们正在为我工​​作。

Hey Guys,

I''ve been perusing the newsgroup here for some time now, and going
through my ever so non-helpful book, Microsoft Visual Basic .NET Step by
Step Version 2003, over and over, and I feel like such a dummy. I read you
fella''s talking up one side and down the other about streams, and can''t for
the life of me get a good grasp of them. I''ve been reading the articles you
toss around to each other but I can''t quite follow them enough to know why
and how I''m supposed to be using streams instead of the FileGet and FilePut
stuff that worked for me in the past.

My dilemma is that I have been using FileGet and FilePut routines for as
long as I can remember, and I don''t know how to be more efficient with
things although I''ve read that streams are so much faster than the old
routines. I have a little file I''m working with that stores names and
address and is searched through on a regular basis, but FileGet and FilePut
seem to be just so dad-blasted slow these days, even on fast machines. I
know these machines should be able to search the entire file in less time
than it takes me to think about it, but gosh it takes quite a little while,
which slows down the program considerably, so there must be a better way.

That Microsoft book I''ve been using says that streams are great, and
even gives a little example of using them. My problem is that I can''t
figure out how to use them in place of the random access file routines
FileGet and FilePut. I''ve tried to figure this out before, and was sent
down the path of serialization. So, I finally got that to work for me
today, and am wonderfully happy about that. All the information I''ve found
however, doesn''t help me to learn how to open a stream to a file and then
send or retrieve record after record to and from, or just pick out any
record I want from it, like I could using a random access file and the
FilePut and FileGet functions.

I''m sorry to be out of date, but if anybody could point me towards
finding out how to do multiple records instead of just a single one, I would
be very greatful.

Here''s a very simplified example of what I''ve managed to put together out of
all the information I''ve run across:

<Serializable()> Public Class blankRecord
<VBFixedString(24)> Public name
<VBFixedString(32)> Public addressLine1
<VBFixedString(32)> Public addressLine2
<VBFixedString(32)> Public addressLine3
End Class

Private Sub saveAddress
Dim record As New blankRecord
Dim fs As New FileStream("c:\test.txt", FileMode.OpenOrCreate)
Dim bf as New
Runtime.Serialization.Formatters.Binary.BinaryForm atter
bf.Serialize(fs, record)
fs.Close()
End Sub

What I don''t understand yet is how I can modify the above code to let me
save more than one address into my address file, like I could if I were
using:

FilePut(fileNumber, record, recordNumber)

Thank you very much for taking time to read my long winded post.

Confused programmer,
Brian

P.S. Maybe if anybody knew of a book or article along the lines of "File
Streams for Dummy''s", I would be most greatful, as I don''t want anybody to
feel they are doing my work for me.

推荐答案

你可以有一个包含数组中所有记录的顶级clas

收集并序列化该类,就像你创建的那样记录


-

Ceers,

Crirus


------------------------------

如果工作是件好事,老板会把这一切都从你那里拿走


--------------------- ---------


" strchild" < ST ****** @ hotmale.com>在消息中写道

news:fi *************** @ newsread1.news.pas.earthlin k.net ...
you can have a top clas that contain all records in an array or some
collection and serialize that class as you did with a record

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"strchild" <st******@hotmale.com> wrote in message
news:fi***************@newsread1.news.pas.earthlin k.net...
嘿伙计们,

我一直在这里阅读新闻组已经有一段时间了,并且通过我那本非常有帮助的书,Microsoft Visual Basic .NET Step by
你这个家伙在一边说话而另一边谈论溪流,并且在我的生活中不能用b $ b来掌握它们。我一直在阅读你扔给对方的文章
但我不能完全理解为什么
以及我应该如何使用流而不是FileGet和
FilePut过去对我有用的东西。

我的困境是,只要我记得,我一直在使用FileGet和FilePut例程
,而且我不喜欢虽然我已经读到流比旧的例程快得多,但我知道如何提高效率。我有一个小文件,我正在使用该商店的名称和
地址,并定期搜索,但FileGet和
FilePut似乎是如此爸爸爆炸这些天,甚至在快速机器上。我知道这些机器应该能够在更短的时间内搜索整个文件,而不是考虑它,但是这需要花费相当多的
,这会减慢程序的速度所以必须有一个更好的方法。

我一直在使用的微软书中说流很棒,而且甚至给出了一个使用它们的例子。我的问题是我无法弄清楚如何使用它们代替随机访问文件例程
FileGet和FilePut。我之前试图解决这个问题,然后被送到了序列化的道路上。所以,我终于有了这个为我工作的今天,我非常高兴。然而,我发现的所有信息都没有帮助我学习如何打开一个文件流然后
发送或检索记录后的记录,或者只是选择我想要的任何
记录,就像我可以使用随机访问文件和
FilePut和FileGet功能一样。

我很抱歉已经过时了,但是如果有人能指出我找到如何做多个记录而不是单个记录,那么我会花很多钱。

这是一个非常简单的例子我设法将我遇到的所有信息中的
组合在一起:

< Serializable()>公共类blankRecord
< VBFixedString(24)>公共名称
< VBFixedString(32)>公共地址线路1
< VBFixedString(32)>公共地址线路2
< VBFixedString(32)>公共地址线3
结束类

私有子保存地址
昏暗记录为新的blankRecord
Dim fs为新FileStream(c:\test.txt,FileMode .OpenOrCreate)
Dim bf as New
Runtime.Serialization.Formatters.Binary.BinaryForm atter
bf.Serialize(fs,record)
fs.Close()
结束子

我不明白的是我如何修改上面的代码让我把多个地址保存到我的地址文件中,就像我可以的那样使用:

FilePut(fileNumber,record,recordNumber)

非常感谢您花时间阅读我的长篇帖子。
困惑的程序员,
Brian

PS也许如果有人知道一本书或文章文件
Streams for Dummy的话,我会非常感激,因为我不想让任何人感觉到他们是为我工作。
Hey Guys,

I''ve been perusing the newsgroup here for some time now, and going
through my ever so non-helpful book, Microsoft Visual Basic .NET Step by
Step Version 2003, over and over, and I feel like such a dummy. I read you fella''s talking up one side and down the other about streams, and can''t for the life of me get a good grasp of them. I''ve been reading the articles you toss around to each other but I can''t quite follow them enough to know why
and how I''m supposed to be using streams instead of the FileGet and FilePut stuff that worked for me in the past.

My dilemma is that I have been using FileGet and FilePut routines for as long as I can remember, and I don''t know how to be more efficient with
things although I''ve read that streams are so much faster than the old
routines. I have a little file I''m working with that stores names and
address and is searched through on a regular basis, but FileGet and FilePut seem to be just so dad-blasted slow these days, even on fast machines. I
know these machines should be able to search the entire file in less time
than it takes me to think about it, but gosh it takes quite a little while, which slows down the program considerably, so there must be a better way.

That Microsoft book I''ve been using says that streams are great, and
even gives a little example of using them. My problem is that I can''t
figure out how to use them in place of the random access file routines
FileGet and FilePut. I''ve tried to figure this out before, and was sent
down the path of serialization. So, I finally got that to work for me
today, and am wonderfully happy about that. All the information I''ve found however, doesn''t help me to learn how to open a stream to a file and then
send or retrieve record after record to and from, or just pick out any
record I want from it, like I could using a random access file and the
FilePut and FileGet functions.

I''m sorry to be out of date, but if anybody could point me towards
finding out how to do multiple records instead of just a single one, I would be very greatful.

Here''s a very simplified example of what I''ve managed to put together out of all the information I''ve run across:

<Serializable()> Public Class blankRecord
<VBFixedString(24)> Public name
<VBFixedString(32)> Public addressLine1
<VBFixedString(32)> Public addressLine2
<VBFixedString(32)> Public addressLine3
End Class

Private Sub saveAddress
Dim record As New blankRecord
Dim fs As New FileStream("c:\test.txt", FileMode.OpenOrCreate)
Dim bf as New
Runtime.Serialization.Formatters.Binary.BinaryForm atter
bf.Serialize(fs, record)
fs.Close()
End Sub

What I don''t understand yet is how I can modify the above code to let me
save more than one address into my address file, like I could if I were
using:

FilePut(fileNumber, record, recordNumber)

Thank you very much for taking time to read my long winded post.

Confused programmer,
Brian

P.S. Maybe if anybody knew of a book or article along the lines of "File
Streams for Dummy''s", I would be most greatful, as I don''t want anybody to
feel they are doing my work for me.



" strchild" < ST ****** @ hotmale.com> schrieb
"strchild" <st******@hotmale.com> schrieb
这里有一个非常简单的例子,说明我已经设法把所有的信息放在一起了


<序列化()>公共类blankRecord
< VBFixedString(24)>公共名称
< VBFixedString(32)>公共地址线路1
< VBFixedString(32)>公共地址线路2
< VBFixedString(32)>公共地址Line3
End Class


缺少数据类型:


< Serializable()>公共类blankRecord

< VBFixedString(24)>公共名称As String

< VBFixedString(32)> Public addressLine1 As String

< VBFixedString(32)> Public addressLine2 As String

< VBFixedString(32)>公共地址线3作为字符串

结束类


启用Option Strict可防止您出现这些错误。

私有子保存地址
Dim record as New blankRecord
Dim fs As New FileStream(" c:\ test.txt",
FileMode.OpenOrCreate)
Dim bf as New
Runtime.Serialization。 Formatters.Binary.BinaryForm atter
bf.Serialize(fs,record)
fs.Close()
End Sub

我还不明白的是我如何修改上面的代码让我把多个地址保存到我的地址文件中,就像我可以使用的那样:

FilePut(fileNumber,record, recordNumber)

非常感谢您花时间阅读我的长篇文章。
Here''s a very simplified example of what I''ve managed to put together
out of all the information I''ve run across:

<Serializable()> Public Class blankRecord
<VBFixedString(24)> Public name
<VBFixedString(32)> Public addressLine1
<VBFixedString(32)> Public addressLine2
<VBFixedString(32)> Public addressLine3
End Class
The data types are missing:

<Serializable()> Public Class blankRecord
<VBFixedString(24)> Public name As String
<VBFixedString(32)> Public addressLine1 As String
<VBFixedString(32)> Public addressLine2 As String
<VBFixedString(32)> Public addressLine3 As String
End Class

Enabling Option Strict prevents you from these errors.
Private Sub saveAddress
Dim record As New blankRecord
Dim fs As New FileStream("c:\test.txt",
FileMode.OpenOrCreate)
Dim bf as New
Runtime.Serialization.Formatters.Binary.BinaryForm atter
bf.Serialize(fs, record)
fs.Close()
End Sub

What I don''t understand yet is how I can modify the above code to let
me save more than one address into my address file, like I could if I
were using:

FilePut(fileNumber, record, recordNumber)

Thank you very much for taking time to read my long winded post.



我不是序列化的朋友,但AFAIK你可以不这样做。

序列化是一种面向对象的方式来存储数据。它按顺序存储了

,而不是通过recored记录,即不能保证所有

记录具有相同的长度 - 但必须假设为随机

访问文件。你可以做什么(使用序列化)是使用或写一个包含所有要存储的实例的
可序列化集合。然后你可以改为
序列化整个集合。


如果我需要一个随机访问文件,我会使用fileget / fileput(没有

更深入体验它的性能),或者我会使用BinaryWriter

将内容写入文件(逐位,整数整数,... 。)。

-

Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html


I''m not a friend of serialization, but AFAIK you can not do it this way.
Serialization is an object oriented way to store data. It''s stored
sequentially, not record by recored, i.e. there is no guarantee that all
records have the same length - but that has to be assumed for a random
access file. What you can do (using serialization) is use or write a
serializable collection containing all instances to be stored. Then you can
serialize the whole collection instead.

If I needed a random access file, I''d use fileget/fileput (without having
deeper experience in it''s performance), or I''d use a BinaryWriter that
writes the contents to the file (bit by bit, integer by integer,...).
--
Armin

http://learn.to/quote
http://www.plig.net/nnq/nquote.html


我害怕我不喜欢不明白你的意思,Cirus。你的意思是只打开文件并加载我存储在其中的每一条记录,一次都是

一次?这对我来说没有意义!我必须管理的一个文件

记录是几百兆字节。


我害怕我再次虚拟而且不知道什么是顶级

是。


如果有人愿意,我可以提供更多关于我的计划的背景,但我没有'$

认为有必要让我的原始帖子比现在更长!


我很感激帮助。


更加困惑,; -S

Brian


" Crirus" <铬**** @ datagroup.ro>在消息中写道

新闻:好的************* @ tk2msftngp13.phx.gbl ...
I''m afraid I don''t understand what you mean, Cirus. Do you mean to just
open the file and load in every last record that I have stored in it, all at
once? That doesn''t make sense to me! One of my files that I have to manage
records in is hundreds of megabytes.

I''m afraid that I''m a dummy yet again and don''t know what a "Top Class"
is.

I can give more background on my program, if anybody wants, but I didn''t
think it necessary to make my original post any longer than it already is!

I do appreciate the help though.

Confused even more, ;-S
Brian

"Crirus" <Cr****@datagroup.ro> wrote in message
news:OK*************@tk2msftngp13.phx.gbl...
你可以有一个顶级的clas包含数组中的所有记录或某些
集合并按照您的记录序列化该类

-
Ceers,
Crirus
<如果工作是好事,那么老板就会把它全部拿走来自你

------------------------------

" strchild" < ST ****** @ hotmale.com>在消息中写道
新闻:fi *************** @ newsread1.news.pas.earthlin k.net ...
you can have a top clas that contain all records in an array or some
collection and serialize that class as you did with a record

--
Ceers,
Crirus

------------------------------
If work were a good thing, the boss would take it all from you

------------------------------

"strchild" <st******@hotmale.com> wrote in message
news:fi***************@newsread1.news.pas.earthlin k.net...
嘿伙计们,

我一直在这里阅读新闻组已经有一段时间了,并且通过我非常有用的书,Microsoft Visual Basic .NET继续步骤
步骤版本2003年,一遍又一遍,我觉得这样的假人。我读到你了
Hey Guys,

I''ve been perusing the newsgroup here for some time now, and going
through my ever so non-helpful book, Microsoft Visual Basic .NET Step by
Step Version 2003, over and over, and I feel like such a dummy. I read you
fella'一边谈论溪流,另一边谈论溪流,不能
fella''s talking up one side and down the other about streams, and can''t


生活我很好地掌握了它们。我一直在读文章
the life of me get a good grasp of them. I''ve been reading the articles


互相折腾但我不能完全跟随它们知道
为什么以及如何我'我应该使用流而不是FileGet和
toss around to each other but I can''t quite follow them enough to know why and how I''m supposed to be using streams instead of the FileGet and


FilePut


FilePut

过去对我有用的东西。

我的困境是我一直在使用FileGet和FilePut例程
作为
stuff that worked for me in the past.

My dilemma is that I have been using FileGet and FilePut routines for as
,只要我记得,我不知道如何更有效地使用
东西,尽管我我们已经知道,流程比旧的
例程要快得多。我有一个小文件,我正在使用它存储名称和
地址,并定期搜索,但FileGet和FilePut
long as I can remember, and I don''t know how to be more efficient with
things although I''ve read that streams are so much faster than the old
routines. I have a little file I''m working with that stores names and
address and is searched through on a regular basis, but FileGet and FilePut
似乎只是如此爸爸爆炸慢这些天,甚至在快速机器上。
seem to be just so dad-blasted slow these days, even on fast machines.



我知道这些机器应该能够以比我考虑的更少
的时间搜索整个文件它,但是它需要相当多的


I know these machines should be able to search the entire file in less time than it takes me to think about it, but gosh it takes quite a little


会大大减慢程序的速度,因此必须有更好的
方式。
我一直在使用的微软书中说流很棒,而且甚至给出了一个使用它们的例子。我的问题是我无法弄清楚如何使用它们代替随机访问文件例程
FileGet和FilePut。我之前试图解决这个问题,然后被送到了序列化的道路上。所以,我终于有了这个为我工作的今天,我非常高兴。我已经
which slows down the program considerably, so there must be a better way.
That Microsoft book I''ve been using says that streams are great, and
even gives a little example of using them. My problem is that I can''t
figure out how to use them in place of the random access file routines
FileGet and FilePut. I''ve tried to figure this out before, and was sent
down the path of serialization. So, I finally got that to work for me
today, and am wonderfully happy about that. All the information I''ve

找到的所有信息

然而,并不能帮助我学习如何打开一个文件流,然后
发送或在记录之后检索记录,或者只是选择我想要的记录,就像我可以使用随机访问文件和
FilePut和FileGet函数一样。

我很抱歉已经过时了,但是如果有人能指出我找到如何做多个记录而不是单个记录,我
however, doesn''t help me to learn how to open a stream to a file and then send or retrieve record after record to and from, or just pick out any
record I want from it, like I could using a random access file and the
FilePut and FileGet functions.

I''m sorry to be out of date, but if anybody could point me towards
finding out how to do multiple records instead of just a single one, I


非常好。

这是一个非常简单的例子,我已经设法用
be very greatful.

Here''s a very simplified example of what I''ve managed to put together out of
组合
>所有信息我遇到过:

< Serializable()>公共类blankRecord
< VBFixedString(24)>公共名称
< VBFixedString(32)>公共地址线路1
< VBFixedString(32)>公共地址线路2
< VBFixedString(32)>公共地址线3
结束类

私有子保存地址
昏暗记录为新的blankRecord
Dim fs为新FileStream(c:\test.txt,FileMode .OpenOrCreate)
Dim bf as New
Runtime.Serialization.Formatters.Binary.BinaryForm atter
bf.Serialize(fs,record)
fs.Close()
结束子

我不明白的是我如何修改上面的代码让我把多个地址保存到我的地址文件中,就像我可以的那样使用:

FilePut(fileNumber,record,recordNumber)

非常感谢您花时间阅读我的长篇帖子。
困惑的程序员,
Brian

PS也许如果有人知道一本书或文章
all the information I''ve run across:

<Serializable()> Public Class blankRecord
<VBFixedString(24)> Public name
<VBFixedString(32)> Public addressLine1
<VBFixedString(32)> Public addressLine2
<VBFixedString(32)> Public addressLine3
End Class

Private Sub saveAddress
Dim record As New blankRecord
Dim fs As New FileStream("c:\test.txt", FileMode.OpenOrCreate)
Dim bf as New
Runtime.Serialization.Formatters.Binary.BinaryForm atter
bf.Serialize(fs, record)
fs.Close()
End Sub

What I don''t understand yet is how I can modify the above code to let me
save more than one address into my address file, like I could if I were
using:

FilePut(fileNumber, record, recordNumber)

Thank you very much for taking time to read my long winded post.

Confused programmer,
Brian

P.S. Maybe if anybody knew of a book or article along the lines of



" File Streams for Dummy'',我会非常感激,因为我不喜欢我不想让任何人
觉得他们正在为我工​​作。


"File Streams for Dummy''s", I would be most greatful, as I don''t want anybody to feel they are doing my work for me.




这篇关于格尔,我找不到答案!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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