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

推荐订阅源

V
Visual Studio Blog
爱范儿
爱范儿
GbyAI
GbyAI
博客园 - 叶小钗
Last Week in AI
Last Week in AI
Jina AI
Jina AI
Microsoft Security Blog
Microsoft Security Blog
云风的 BLOG
云风的 BLOG
C
Check Point Blog
H
Help Net Security
P
Proofpoint News Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
大猫的无限游戏
大猫的无限游戏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
B
Blog RSS Feed
Y
Y Combinator Blog
U
Unit 42
T
Tailwind CSS Blog
MyScale Blog
MyScale Blog
N
Netflix TechBlog - Medium
S
SegmentFault 最新的问题
J
Java Code Geeks
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

博客园 - wgscd

Git 无法访问 GitHub(unable to access ‘https://github.com/.../.git‘)问题解决教程 RapidOcrNet文字识别OCR C#+Audio绘制麦克风波形 一共免费大模型API AI聊天对话界面的HTML代码。 纯JavaScript代码实现保存Canvas图片到电脑 WPF鼠标拖动改变图片透明度 Fiddler自定义规则保存图片和提示The system proxy was changed自动重连 缩放 div 浏览器语音识别-webkitSpeechRecognition HTML获取摄像头画面,拍照截图保存 JS摄像头手势识别-Handsfree.js HTML,JS 模拟聊天界面UI JS获取元素相对窗口的位置和大小 C# 判断是否安装了ffmpeg shadow-root中的元素定位方法 JS MutationObserver监听DOM元素改变 Webview2动态设置页面video的Blob进行播放 WPF刮刮乐 JS利用浏览器进行语言识别 WPF设置默认语言地区CultureInfo VS2022推送代码 到github错误: CertGetCertificateChain trust error CERT_TRUST_IS_PARTIAL_CHAIN的解决办法 C#正则表达式匹配候选词 使用ffmpeg去除音频静音
C# 文件分割和文件合并
wgscd · 2025-01-14 · via 博客园 - wgscd

C# 文件分割和文件合并

        void SplitFile()
        {

            string sourceFile = "Old.mp4"; // 源文件路径
            string outputFile1 = "part1.bin"; // 第一个输出文件路径(10KB)
            string outputFile2 = "part2.bin"; // 第二个输出文件路径(剩余部分)

            int firstFileSize = 10 * 1024; // 第一个文件大小为 10KB(10 * 1024 字节)

            // 打开源文件
            using (FileStream sourceStream = File.OpenRead(sourceFile))
            {
                // 创建第一个输出文件
                using (FileStream outputStream1 = File.Create(outputFile1))
                {
                    // 读取并写入第一个文件的 10KB 数据
                    byte[] buffer = new byte[firstFileSize];
                    int bytesRead = sourceStream.Read(buffer, 0, buffer.Length);
                    outputStream1.Write(buffer, 0, bytesRead);
                }

                // 创建第二个输出文件
                using (FileStream outputStream2 = File.Create(outputFile2))
                {
                    // 读取并写入剩余的数据
                    byte[] buffer = new byte[1024]; // 1KB 缓冲区
                    int bytesRead;
                    while ((bytesRead = sourceStream.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        outputStream2.Write(buffer, 0, bytesRead);
                    }
                }
            }


        }

        void MergeFile()
        {

            string file1 = "part1.bin"; // 第一个二进制文件路径
            string file2 = "part2.bin"; // 第二个二进制文件路径
            string outputFile = "Merged.mp4"; // 合并后的文件路径

            // 打开输出文件流
            using (FileStream outputStream = File.Create(outputFile))
            {
                // 读取并写入第一个文件
                using (FileStream inputStream = File.OpenRead(file1))
                {
                    inputStream.CopyTo(outputStream); // 将第一个文件内容复制到输出文件
                }

                // 读取并写入第二个文件
                using (FileStream inputStream = File.OpenRead(file2))
                {
                    inputStream.CopyTo(outputStream); // 将第二个文件内容复制到输出文件
                }
            }

        }

fffffffffffffffff

test red font.

posted @ 2025-01-14 09:47  wgscd  阅读(188)  评论()    收藏  举报