惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
S
Securelist
D
Docker
The Register - Security
The Register - Security
GbyAI
GbyAI
Recorded Future
Recorded Future
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
罗磊的独立博客
博客园 - 【当耐特】
F
Full Disclosure
WordPress大学
WordPress大学
腾讯CDC
小众软件
小众软件
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
SecWiki News
SecWiki News
L
Lohrmann on Cybersecurity
I
InfoQ
MyScale Blog
MyScale Blog
量子位
Cyberwarzone
Cyberwarzone
博客园 - 三生石上(FineUI控件)
The Hacker News
The Hacker News
F
Fortinet All Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
博客园_首页
H
Help Net Security
K
Kaspersky official blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Webroot Blog
Webroot Blog
Blog — PlanetScale
Blog — PlanetScale
V
Vulnerabilities – Threatpost
Y
Y Combinator Blog
The Cloudflare Blog
P
Proofpoint News Feed
V
Visual Studio Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tailwind CSS Blog
爱范儿
爱范儿
P
Privacy International News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
B
Blog RSS Feed

博客园 - 朱煜

项目经理与客户沟通的宜与忌 转 FileStream Read File c#描述异常处理语句try、catch、finally执行时的相互关系 C#计算文件的MD5值实例 C#获取文件MD5字符串 金旭亮老师的Scoekt编程摘要 Winfrom动态创建控件 多个文件合并成一个大文件后,无法打开,需要从以下几个方面找出问题? 腰围2尺1,2,3,4,5,6,7,8寸分别等于是多少厘米/英寸(对照表) 字符编码中的英文字母、汉字占有的字节长度。 Socket Programming in C#--Conclusion Socket Programming in C#--Server Side Socket Programming in C#--Multiple Sockets Socket Programming in C#--Getting Started Socket Programming in C#--Introduction C#中的is,as关键字 委托/事件与观察者模式 发布符合 .NET Framework 准则的事件(C# 编程指南) 在职研究生硕士学位证书查询和认证方式
filestream read方法 循环读取固定文件
朱煜 · 2014-04-22 · via 博客园 - 朱煜

1、循环读取啊,byte[]可以定义为1024或者2049等等,不要超过int的maxvalue就可以。
然后取出来操作完再去取。

 1  FileStream stream = new FileStream(path);
 2  byte[] writeData = new byte[8192];
 3   // Use the ReadAllBytesFromStream to read the stream.
 4   while (true)
 5   {
 6        int size = stream.Read(writeData, 0, writeData.Length);
 7        if (size > 0)
 8        {
 9             //你操作数据的代码
10       }
11        else
12        {
13             break;
14        }
15   }
16   stream.Close();

2、C# filestream.Read用在while循环有啥用?
FileStream fs = File.OpenRead("C:\\test.txt");
byte[] arr = new byte[100];
while (filestream.Read(arr, 0, arr.Length)>0)
{
Console.WriteLine(data.GetString(arr));
}
回答:循环读取文件,每次只读100个字节

string str = "C:\\test.txt";
                        if (!File.Exists(str))     ///检测文件是否存在
                           {
                                       MessageBox.Show("文件不存在,请查看客户端是否已经上传数据!");
                           }
                       else
                          {   
                                 FileStream fop = File.OpenRead(str);
                                 byte[] arr = new byte[1000];
                                 while (fop.Read(arr, 0, arr.Length) > 0)    ///这个循环会将文件所有的内容都读取出来
                                  {
                                  ClientSocket[1].Send(arr, 0, arr.Length,0);
                                  }
                                 fop.Close();
                             }