分割程序类

namespace fileIncise {     using System;     using System.Data;     using System.Configuration;     using System.Web;     using System.Web.Security;     using System.Web.UI;     using System.Web.UI.WebControls;     using System.Web.UI.WebControls.WebParts;     using System.Web.UI.HtmlControls;     //     using System.IO;     using System.Text;     /// <summary>     /// Incise 的摘要说明:文件切割类     /// </summary>     public class Incise     {         /// <summary>         /// 应用程序的主入口点         /// </summary>         [STAThread]         static void Main(string[] args) {             if (args[0] == "s") {                 int i;                 FileStream fr = new FileStream(args[1], FileMode.Open, FileAccess.Read);                 int filesize = Convert.ToInt32(fr.Length) / Convert.ToInt32(args[2]);                 StreamWriter fwlist = new StreamWriter(args[1] + "." + "list", false);                 for (i = 1; i <= Convert.ToInt32(args[2]); i++)                 {                     byte[] byteread = new byte[filesize];                     fr.Read(byteread, 0, filesize);                     FileStream fw = new FileStream(args[1] + "." + i, FileMode.CreateNew, FileAccess.Write);                     fwlist.WriteLine(args[1] + "." + i);                     foreach (byte bnext in byteread)                         fw.WriteByte(bnext);                     fw.Close();                 }                 if (fr.Length != fr.Position)                 {                     byte[] byteread = new byte[Convert.ToInt32(fr.Length) - filesize * (i - 1)];                     fr.Read(byteread, 0, Convert.ToInt32(fr.Length) - filesize * (i - 1));                     FileStream fw = new FileStream(args[1] + "." + i, FileMode.CreateNew, FileAccess.Write);                     fwlist.WriteLine(args[1] + "." + i);                     foreach (byte bnext in byteread)                         fw.WriteByte(bnext);                     fw.Close();                 }                 fr.Close();                 fwlist.Flush();                 fwlist.Close();                 Console.WriteLine("文件分割结束");             }             if (args[0] == "m")             {                 StreamReader frlist = new StreamReader(args[1] + "." + "list");                 FileStream fw = new FileStream(args[1], FileMode.Append, FileAccess.Write);                                 string sline;                 sline = frlist.ReadLine();                                 while (sline != null)                 {                     FileStream fr = new FileStream(sline, FileMode.Open, FileAccess.Read);                                         byte[] byteread = new byte[fr.Length];                     fr.Read(byteread, 0, Convert.ToInt32(fr.Length));                                         foreach (byte bnext in byteread)                         fw.WriteByte(bnext);                     fr.Close();                     sline = frlist.ReadLine();                                                         }                 frlist.Close();                 fw.Close();                 Console.WriteLine("文件合并结束");             }         }         public Incise()         {             //             // TODO: 在此处添加构造函数逻辑             //         }     } } 编译:csc /out:Incise.exe Incise.cs 使用:Incise s 要分割文件的文件名 分割成几个文件              如:Incise s aaa.avi 5             Incise m 合并后的文件名称              如:Incise m aaa.avi
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值