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

推荐订阅源

Martin Fowler
Martin Fowler
博客园 - 【当耐特】
GbyAI
GbyAI
M
MIT News - Artificial intelligence
Microsoft Azure Blog
Microsoft Azure Blog
A
About on SuperTechFans
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
腾讯CDC
F
Fortinet All Blogs
IT之家
IT之家
WordPress大学
WordPress大学
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Last Week in AI
Last Week in AI
Google DeepMind News
Google DeepMind News
Jina AI
Jina AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
D
DataBreaches.Net
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Help Net Security
V
Visual Studio Blog
小众软件
小众软件
Y
Y Combinator Blog

博客园 - RedSoft

需求分析——你好,我好,大家好! PHP问题列表(持续更新) [收藏]mysql 性能的检查和调优方法 【收藏】hibernate 集合映射inverse和cascade详解 个人网站开通。 【原】轻量级的数据交换格式——初识Json(下) 【原】轻量级的数据交换格式——初识Json(上) 【原】初学Jquery 【原】初学Flex之简单图片查看器 【原】基于asp.net的Web开发架构探索 JavaScript使用技巧精萃 WinForm UI设计与开发思路(转) C#编程风格约定 C#常用正则表达式 写了个MVC/多层的Demo…… EnableViewState,与TextBOx控件状态改变的关系 文本框+层模拟下拉框,并实现输入自动提示和过滤 软件史上最伟大的十大程序员(图文) sql 常用语句积累
将目录下的图片文件写成一个二进制大文件
RedSoft · 2008-03-12 · via 博客园 - RedSoft

这个问题弄得我昨晚都没吃饭,终于搞定了!

DirectoryInfo di = new DirectoryInfo(folderallpath);//folderallpath是目录名  
FileInfo fiobj = new FileInfo(folderallpath + "\\total.obj"); //  total.obj就是二进制大文件
FileStream fsobj = fiobj.Open(FileMode.Append,FileAccess.Write); //这里应该用FileMode.Append,循环写入的时候,原有文件才不会被覆盖
foreach (FileInfo fi in di.GetFiles("*.*"))  
            {  
                if (fi.Extension.ToLower() == ".jpg"  ¦ ¦ fi.Extension.ToLower() == ".png"  ¦ ¦ fi.Extension.ToLower() == ".tif")  
                {   

                    string path = folderallpath + "/" + fi.Name;
                    int length = Int32.Parse(fi.Length.ToString());  

                    if (length != 0)  
                    {  
                        Byte[] FileByteArray = new Byte[length];
                        FileStream fspic = new FileStream(path, FileMode.Open, FileAccess.Read); 
                        fspic.Read(FileByteArray, 0, System.Convert.ToInt32(fspic.Length));
                        fspic.Flush();  
                        fsobj.Write(FileByteArray,0,length);  
                    }  
                }  
            }  
fsobj.Flush();  
fsobj.Close();

大功告成~~