读/写文件 [英] Read/Write Files

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

问题描述

我不仅要读/写文本文件,还需要二进制文件。好像在二进制文件上,它不是文件的最后10%。


-

谢谢



---

外发邮件经过无病毒认证。

由AVG反病毒系统检查( http://www.grisoft.com)

版本:6.0.538 /病毒数据库:333 - 发布日期:11/10/2003

解决方案

*" Tibby" < TI ************* @ hotmail.com> scripsit:

我不仅需要读/写文本文件,还需要二进制文件。*好像在二进制文件上,它不是最后10%的
文件。




发布你的代码。


-

Herfried K. Wagner [MVP ]

< http://www.mvps.org/dotnet>


" Tibby" < TI ************* @ hotmail.com> schrieb

我不仅要读/写文本文件,还需要二进制文件。它好像在二进制文件上,它不是最后10%的
文件。




你怎么读?

-

Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


< blockquote>这里是代码:


Public Sub TestReadWrite(ByVal FileName As String)

Dim FS As FileStream

Dim BR As BinaryReader

Dim BW As BinaryWriter

Dim Storeage()As Byte

FS =新FileStream(C:\ ;& FileName,FileMode.Open,FileAccess.Read)

BR =新的二进制读取器(FS)

Storeage = BR.ReadBytes(FS.Length)

BR.Close()

FS.Close()

FS =新FileStream(" C:\ Copy of & FileName,FileMode.CreateNew,

FileAccess.Write)

BW =新BinaryWriter(FS)

BW.Write(Storeage)

BW.Close()

FS.Close()

结束子


Don''问我为什么或如何,但现在似乎工作得很好。所有我可以说是
可以说是Grrrr ....

重点是,我用它来替换filecopy / ftp函数。对于FTP,

有一个服务器应用程序,然后客户端应用程序连接,并且数据流

被加密发送到客户端。再次,urgghhhh ......

我想我可能一直在尝试将其读/写为字符串

而不是字节。嗯......


再次感谢

Tibby


" Herfried K. Wagner [MVP]" <喜*************** @ gmx.at>在消息中写道

news:bp ************* @ ID-208219.news.uni-berlin.de ...

*Tibby < TI ************* @ hotmail.com> scripsit:

我不仅要读/写文本文件,还需要二进制文件。似乎
喜欢二进制文件,它不是文件的最后10%。



发布你的代码。

- -
Herfried K. Wagner [MVP]
< http://www.mvps.org/dotnet>



I need to read/write not only text files, but binary as well. It seems like on binary files, it doesn''t right the last 10% of the file.

--
Thanks


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.538 / Virus Database: 333 - Release Date: 11/10/2003

解决方案

* "Tibby" <ti*************@hotmail.com> scripsit:

I need to read/write not only text files, but binary as well.* It seems like on binary files, it doesn''t right the last 10% of
the file.



Post your code.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>


"Tibby" <ti*************@hotmail.com> schrieb

I need to read/write not only text files, but binary as well. It
seems like on binary files, it doesn''t right the last 10% of the
file.



How do you read?
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


Here''s the code:

Public Sub TestReadWrite(ByVal FileName As String)
Dim FS As FileStream
Dim BR As BinaryReader
Dim BW As BinaryWriter
Dim Storeage() As Byte
FS = New FileStream("C:\" & FileName, FileMode.Open, FileAccess.Read)
BR = New BinaryReader(FS)
Storeage = BR.ReadBytes(FS.Length)
BR.Close()
FS.Close()
FS = New FileStream("C:\Copy of " & FileName, FileMode.CreateNew,
FileAccess.Write)
BW = New BinaryWriter(FS)
BW.Write(Storeage)
BW.Close()
FS.Close()
End Sub

Don''t ask me why or how, but now it seems to be working just fine. All I
can say is Grrrr....
The point is, I''m using it to replace filecopy/ftp functions. For the FTP,
there''s a server app, then the client app connects in, and the data stream
is sent encrypted to the client. Once again, urgghhhh......
I think what I may have been doing is trying to read/write it as string
instead of byte. Hmmm...

Thanks again
Tibby

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:bp*************@ID-208219.news.uni-berlin.de...

* "Tibby" <ti*************@hotmail.com> scripsit:

I need to read/write not only text files, but binary as well. It seems like on binary files, it doesn''t right the last 10% of the file.



Post your code.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>



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

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