文件剪切

9G多的文件,携带不便,只要头上1.5G就足够了,所以剪切下来,很简单,没怎么注释,代码:
 1  using  System;
 2  using  System.Collections.Generic;
 3  using  System.Linq;
 4  using  System.Text;
 5  using  System.IO;
 6 
 7  namespace  FileCut
 8  {
 9       class  Program
10      {
11           static   void  Main( string [] args)
12          {
13               if  (args.Length  <   1 )
14              {
15                  Console.WriteLine( " Please input source file name! " );
16                   return ;
17              }
18               string  Filename  =  args[ 0 ];
19              Console.WriteLine(Filename);
20               if  ( ! File.Exists(Filename))
21              {
22                  Console.WriteLine( " Make sure the file exists! " );
23                   return ;
24              }
25              FileStream fs  =   new  FileStream(Filename, FileMode.Open, FileAccess.Read);
26              BinaryReader br  =   new  BinaryReader(fs);
27              FileStream fo  =   new  FileStream(Filename  +   " .new " , FileMode.CreateNew);
28              BinaryWriter bw  =   new  BinaryWriter(fo);
29               try
30              {
31                   for  ( int  i  =   0 ; i  <  ( /* test 5 */ 1024   +   512 ); i ++ )
32                  {
33                       byte [] beb  =  br.ReadBytes( 1024   *   1024 );
34                      bw.Write(beb);
35                  }
36              }
37               catch  (Exception ex)
38              {
39                  Console.WriteLine(ex.Message);
40              }
41               finally
42              {
43                  br.Close();
44                  bw.Close();
45                  fs.Close();
46                  fo.Close();
47              }
48          }
49      }
50 

 

转载于:https://www.cnblogs.com/junuh/archive/2010/06/18/1760626.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值