public override byte[] WriteBytes() { byte[] msg = new byte[MyHead.Total_Length]; Tools.CopyAll(0, MyHead.Write(), ref msg); msg[12] = Reserved; return(msg); }
public static void Main(string[] args) { string SCRATCH_FILES_PATH = "ziptest"; string scratchPath = "ziptest.zip"; using (var archive = ZipArchive.Create()) { DirectoryInfo di = new DirectoryInfo(SCRATCH_FILES_PATH); foreach (var fi in di.GetFiles()) { archive.AddEntry(fi.Name, fi.OpenRead(), true); } FileStream fs_scratchPath = new FileStream(scratchPath, FileMode.OpenOrCreate, FileAccess.Write); archive.SaveTo(fs_scratchPath, CompressionType.Deflate); fs_scratchPath.Close(); //archive.AddAllFromDirectory(SCRATCH_FILES_PATH); //archive.SaveTo(scratchPath, CompressionType.Deflate); using (FileStream fs = new FileStream("ziphead.zip", FileMode.OpenOrCreate, FileAccess.ReadWrite)) { MyHead mh = new MyHead(); byte[] headData = mh.Create(); fs.Write(headData, 0, headData.Length); // SharpCompress.IO.OffsetStream ofs = new IO.OffsetStream(fs, fs.Position); archive.SaveTo(ofs, CompressionType.Deflate); } } //write my zipfile with head data using (FileStream fs = new FileStream("mypack.data.zip", FileMode.Create, FileAccess.ReadWrite, FileShare.Read)) { MyHead mh = new MyHead(); byte[] headData = mh.Create(); fs.Write(headData, 0, headData.Length); using (FileStream fs2 = new FileStream(scratchPath, FileMode.Open, FileAccess.Read)) { byte[] buf = new byte[1024]; int rc = 0; while ((rc = fs2.Read(buf, 0, buf.Length)) > 0) { fs.Write(buf, 0, rc); } } } // //read my zip file with head // using (FileStream fs = new FileStream("mypack.data.zip", FileMode.Open, FileAccess.Read, FileShare.Read)) { byte[] buf = new byte[1024]; int offset = fs.Read(buf, 0, buf.Length); System.Diagnostics.Debug.Assert(offset == 1024); //fs.Position = 0L; SharpCompress.IO.OffsetStream substream = new SharpCompress.IO.OffsetStream(fs, offset); ZipArchive zip = ZipArchive.Open(substream, Options.KeepStreamsOpen);//cann't read //ZipArchive zip = ZipArchive.Open(fs, Options.None); //will throw exption //ZipArchive zip = ZipArchive.Open(fs, Options.KeepStreamsOpen);//cann't read foreach (ZipArchiveEntry zf in zip.Entries) { Console.WriteLine(zf.Key); //bug:the will not none in zipfile } int jjj = 0; jjj++; } }
public override byte[] WriteBytes() { byte[] msg = new byte[MyHead.Total_Length]; Tools.CopyAll(0, MyHead.Write(), ref msg); Tools.CopyAll(12, BitConverter.GetBytes(ReverseByteOrder.ReverseBytes(Msg_Id)), ref msg); Tools.CopyAll(20, BitConverter.GetBytes(ReverseByteOrder.ReverseBytes(Result)), ref msg); return(msg); }
/// <summary> /// /// </summary> /// <returns></returns> public override byte[] WriteBytes() { byte[] msgByts = new byte[MyHead.Total_Length]; //注释掉空值 无需赋值 Tools.CopyAll(0, MyHead.Write(), ref msgByts); //Tools.CopyAll(12, BitConverter.GetBytes(ReverseByteOrder.ReverseBytes(Msg_Id)), ref msgByts);//msgId由网关生成 Tools.CopyAll(20, BitConverter.GetBytes(Pk_total), ref msgByts); Tools.CopyAll(21, BitConverter.GetBytes(Pk_number), ref msgByts); Tools.CopyAll(22, BitConverter.GetBytes(Registered_Delivery), ref msgByts); Tools.CopyAll(23, BitConverter.GetBytes(Msg_level), ref msgByts); Tools.CopyAll(24, Tools.StringToBytes(Service_Id), ref msgByts, 10); Tools.CopyAll(34, BitConverter.GetBytes(Fee_UserType), ref msgByts); //CopyAll(35, StringToBytes(Fee_terminal_Id), ref msgByts); Tools.CopyAll(67, BitConverter.GetBytes(Fee_terminal_type), ref msgByts); Tools.CopyAll(68, BitConverter.GetBytes(TP_pId), ref msgByts); Tools.CopyAll(69, BitConverter.GetBytes(TP_udhi), ref msgByts); Tools.CopyAll(70, BitConverter.GetBytes(Msg_Fmt), ref msgByts); Tools.CopyAll(71, Tools.StringToBytes(Msg_src), ref msgByts, 6); Tools.CopyAll(77, Tools.StringToBytes(FeeType), ref msgByts, 2); Tools.CopyAll(79, Tools.StringToBytes(FeeCode), ref msgByts, 6); //CopyAll(85, StringToBytes(ValId_Time), ref msgByts); //CopyAll(102, StringToBytes(At_Time), ref msgByts); Tools.CopyAll(119, Tools.StringToBytes(Src_Id), ref msgByts, 21); Tools.CopyAll(140, BitConverter.GetBytes(DestUsr_tl), ref msgByts); Tools.CopyAll(141, Tools.StringToBytes(Dest_terminal_Id), ref msgByts, 32); Tools.CopyAll(173, BitConverter.GetBytes(Dest_terminal_type), ref msgByts); /**TP_udhi 协议 * 6 位协议头格式:05 00 03 XX MM NN * XX,这批短信的唯一标志,这个标志是否唯一并不是很重要。 * MM, 这批短信的数量 * NN, 这批短信的第几条 * * CMPP 协议发长短信: * 1. TP_udhi 设置为 0x01 * 2. Msg_Content:按 TP_udhi 协议填写 6 字节或者 7 字节的 TP_udhi 协议头然后加上经过USC2 编码的消息内容。由 TP_udhi 协议头和消息内容体组成的 Msg_Content 总长度不能超过 140 个字节 * 3. Msg_Fmt:设置为 0x08 UCS2 编码; * 4. Pk_total 和 Pk_number 可以不设置,如果要设置,就要分别跟 TP_udhi 的 MM 和 NN 字段一致 * **/ if (_isLongMsg) { byte[] longMsgHeadBytes = new byte[] { 05, 00, 03, _longMsgId, Pk_total, Pk_number }; Tools.CopyAll(174, BitConverter.GetBytes(Msg_Length + 6), ref msgByts); Tools.CopyAll(175, longMsgHeadBytes, ref msgByts, 6); Tools.CopyAll(181, _contentByts, ref msgByts, Msg_Length); } else { Tools.CopyAll(174, BitConverter.GetBytes(Msg_Length), ref msgByts); Tools.CopyAll(175, _contentByts, ref msgByts, Msg_Length); } //CopyAll(175+Msg_Length, StringToBytes(LinkID), ref msgByts,20); return(msgByts); }
void OnTriggerEnter2D(Collider2D collider) { MyHead head = collider.gameObject.GetComponent <MyHead>(); if (head != null) { Settings.Instance.PlaySound("Bird"); StartCoroutine(HeadCarrying(head)); } }
private void ProcessPop(MyHead head, PopTransition <TState> pdaTransition, TTransition sourceTransition) { var record = new PopHistoryRecord <TState, TTransition, TPosition, TContext>( pdaTransition.NextState, sourceTransition, myTransitionProvider.Target(sourceTransition), head.CurrentContext); myPopHistory.AddToPopHistory(head.StackTop, record); foreach (var newTop in head.StackTop.Pop()) { ProcessPopForNewTop(pdaTransition.NextState, sourceTransition, head.CurrentContext, newTop); } }
IEnumerator HeadCarrying(MyHead head) { head.TakeHead(0); head.transform.SetParent(transform); GetComponent <CircleCollider2D>().enabled = false; yield return(new WaitForSeconds(carryTime)); transform.DetachChildren(); head.TakeHead(rb.velocity.x); yield return(new WaitForSeconds(1)); GetComponent <CircleCollider2D>().enabled = true; }
/// <summary> /// /// </summary> /// <returns></returns> public override byte[] WriteBytes() { byte[] msgByts = new byte[MyHead.Total_Length]; string strTimestamp = DateTime.Now.ToString("MMddHHmmss"); Timestamp = UInt32.Parse(strTimestamp); // AuthenticatorSource = SP_ID + "\0\0\0\0\0\0\0\0\0" + _pwd + strTimestamp; // Tools.CopyAll(0, MyHead.Write(), ref msgByts); Tools.CopyAll(12, Tools.StringToBytes(SP_ID), ref msgByts, 6); Tools.CopyAll(18, MyMD5.GetMD5Byts_32(AuthenticatorSource), ref msgByts); msgByts[34] = Version; Tools.CopyAll(35, BitConverter.GetBytes(ReverseByteOrder.ReverseBytes(Timestamp)), ref msgByts); // return(msgByts); }
private void ProcessPush(MyHead head, PushTransition <TState, TStackSymbol> pdaTransition, TTransition sourceTransition) { var newData = pdaTransition.Pushed; var newState = pdaTransition.NextState; var newPosition = myTransitionProvider.Target(sourceTransition); var processed = myCacheProvider.Visited(newPosition, newState, newData, out var previousContext); if (processed) { var prevTop = previousContext.StackTop; prevTop.AddParent(head.StackTop); myContextProcessor.InheritContextsOnPush( head.CurrentContext, previousContext, pdaTransition.NextState, pdaTransition.Pushed, sourceTransition, true); foreach (var record in myPopHistory.GetHistoryForNode(prevTop)) { ProcessPopForNewTop(record.NextState, record.SourceTransition, record.InheritFrom, head.StackTop); } } else { var newTop = head.StackTop.Push(newData); var newHead = NewHead(newState, newTop, newPosition, null); myContextProcessor.InheritContextsOnPush( head.CurrentContext, newHead.CurrentContext, pdaTransition.NextState, pdaTransition.Pushed, sourceTransition, false); myCacheProvider.Visit(newPosition, newState, newData, newHead.CurrentContext); myProcessing.Push(newHead); } }
private MyHead NewHead( TState state, GssNode <TStackSymbol, TGssData> stackTop, TPosition position, TContext reuseContext) { var head = new MyHead(state, stackTop, position); if (reuseContext != null) { head.CurrentContext = reuseContext; } else { head.CurrentContext = myContextProcessor.HeadToContext(head); } return(head); }
private void ProcessSkip(MyHead head, SkipTransition <TState> pdaTransition, TTransition sourceTransition) { var newData = head.StackTop.Symbol; var newState = pdaTransition.NextState; var newTop = head.StackTop; var newPosition = myTransitionProvider.Target(sourceTransition); var processed = myCacheProvider.VisitedOnPop(newPosition, newState, newTop, out var previousContext); if (processed) { myContextProcessor.InheritContextsOnSkip( head.CurrentContext, previousContext, pdaTransition.NextState, sourceTransition, true); } else { MyHead newHead; if (pdaTransition.ChangeContext) { newHead = NewHead(newState, newTop, newPosition, null); myContextProcessor.InheritContextsOnSkip( head.CurrentContext, newHead.CurrentContext, pdaTransition.NextState, sourceTransition, false); } else { newHead = NewHead(newState, newTop, newPosition, head.CurrentContext); } myCacheProvider.VisitOnPop(newPosition, newState, newTop, newHead.CurrentContext); myProcessing.Push(newHead); } }
public static void Main(string[] args) { //测试序列化 List <IRQ_VPLDocInfo_Json> vpldocjsons = new List <IRQ_VPLDocInfo_Json>(); for (int i = 0; i < 1; i++) { IRQ_VPLDocInfo_Json docjs = new IRQ_VPLDocInfo_Json(); docjs.Author = "me_" + i.ToString(); docjs.CodeType = VPL_CodeType.CSharp; docjs.CreateDate = DateTime.Now; docjs.Description = ""; docjs.IsCodeMode = false; docjs.IsNoRobotMode = true; docjs.LastUpdate = DateTime.Now; docjs.NoRobotMode_LastPlatId = ""; docjs.OnCloudSvr = false; docjs.PackageUniqueId = ""; docjs.PackageVersion = "2.0"; docjs.Source = IRQ_FileDocSource.User; docjs.Ver = "2.0"; vpldocjsons.Add(docjs); } string docJsonStr = SimpleJsonEx.SimpleJson.SerializeObject(vpldocjsons); using (FileStream fs = new FileStream("test_array.json", FileMode.OpenOrCreate, FileAccess.Write)) { using (StreamWriter sw = new StreamWriter(fs, Encoding.UTF8)) { sw.Write(docJsonStr); } } //反序列化 string docJosnStr2 = ""; using (StreamReader sr = new StreamReader("test_array.json", Encoding.UTF8)) { docJosnStr2 = sr.ReadToEnd(); } List <IRQ_VPLDocInfo_Json> redocJsons = SimpleJsonEx.SimpleJson.DeserializeObject <List <IRQ_VPLDocInfo_Json> >(docJosnStr2); char[] invalid1 = Path.GetInvalidFileNameChars(); char[] invalid2 = Path.GetInvalidPathChars(); List <char> invalidChars = new List <char>(); invalidChars.AddRange(invalid1); for (int i = 0; i < invalid2.Length; i++) { if (invalidChars.Contains(invalid2[i]) == false) { invalidChars.Add(invalid2[i]); } } StringBuilder sb = new StringBuilder(); for (int i = 0; i < invalidChars.Count; i++) { sb.Append(string.Format("{0}", (int)invalidChars[i])); if (i != invalidChars.Count - 1) { sb.Append(","); } } string chars = sb.ToString(); Console.WriteLine(chars); // "'\"','<','>','|','\0','','','','','','','\a','\b','\t','\n','\v','\f','\r','','','','','','','','','','','','','','','','','','',':','*','?','\\','/'" int timestart = Environment.TickCount; ResourceService.Init(); // Stopwatch swRead = new Stopwatch(); // swRead.Start(); // IFilePackerStrategy urobot = ResourceService.GetLib(IRQ_FileType.Robot); //byte[] strInfo= urobot.OpenFile("kaka/1.png"); //urobot.DelDir("kaka"); //swRead.Stop(); //Console.WriteLine("end:"+swRead.ElapsedMilliseconds.ToString()+" ms"); //return; // //增加文件 IFileSysPackerStrategy fps = ResourceService.GetLib(IRQ_FileType.TempLeadInRes); FileStream fsadd = new FileStream("mypack.data.zip", FileMode.Open, FileAccess.Read); byte[] buf_add = new byte[fsadd.Length]; fsadd.Read(buf_add, 0, buf_add.Length); fsadd.Close(); fps.Packer.BeginUpdate(fps); if (fps.FileExists("/test/mypack.data.zip")) { byte[] testReadBuf = fps.OpenFile("/test/mypack.data.zip"); fps.DelFile("/test/mypack.data.zip"); } fps.AddFile("/test/mypack.data.zip", buf_add, DateTime.Now); //addfile fps.AddFile("/test/dir2/mypack2.data.zip", buf_add, DateTime.Now); //addfile fps.UpdateFile("/test/dir2/mypack2.data.zip", new byte[] { 1, 2, 3, 4 }, DateTime.Now); fps.AddFile("/test2/mypack.data.zip", buf_add, DateTime.Now); //addfile fps.RenameFile("/test2/mypack.data.zip", "/test2/mypack2.data.zip"); fps.RenameDir("test", "test3"); List <string> getDirs = new List <string>(); fps.GetDirs(out getDirs); fps.Clean(); fps.AddFile("/test3/mypack.data.zip", buf_add, FileEntryInfo.DateTimeFromStr_STC("2016-01-01 12:12:12")); //addfile fps.AddFile("/test4/mypack.data.zip", buf_add, DateTime.Now); //addfile getDirs = new List <string>(); fps.GetDirs(out getDirs); DateTime dtupdate = fps.GetUpdateDate("test3/mypack.data.zip"); List <string> filenames = new List <string>(); int totalSize = 0; fps.GetFiles("test3", out filenames, out totalSize); fps.DelDir("test3"); fps.RenameDir("test4", "test"); fps.Packer.EndUpdate(fps, true); Console.WriteLine("耗时:" + (Environment.TickCount - timestart).ToString() + " ms"); Console.Read(); return; string SCRATCH_FILES_PATH = "ziptest"; // { //test //CompressionType.LZMA 10次 34175ms 242k //CompressionType.PPMd 10次 68678ms 319k //CompressionType.Deflate 10次 3006ms 428k //CompressionType.BZip2 10次 10103ms 335k //CompressionType.GZip not support //CompressionType.Rar not support //CompressionType.BCJ2 not support //CompressionType.BCJ not support Stopwatch sw = new Stopwatch(); sw.Start(); //for (int i = 0; i < 10; i++) { using (var archive = ZipArchive.Create()) { DirectoryInfo di = new DirectoryInfo(SCRATCH_FILES_PATH); foreach (var fi in di.GetFiles()) { archive.AddEntry(fi.Name, fi.OpenRead(), true); } FileStream fs_scratchPath = new FileStream("compresstimetest.zip", FileMode.OpenOrCreate, FileAccess.Write); archive.SaveTo(fs_scratchPath, CompressionType.Deflate); fs_scratchPath.Close(); } //break; //} sw.Stop(); Console.WriteLine("10time (ms):" + sw.ElapsedMilliseconds.ToString()); } string scratchPath = "ziptest.zip"; using (var archive = ZipArchive.Create()) { DirectoryInfo di = new DirectoryInfo(SCRATCH_FILES_PATH); foreach (var fi in di.GetFiles()) { archive.AddEntry(fi.Name, fi.OpenRead(), true); } FileStream fs_scratchPath = new FileStream(scratchPath, FileMode.OpenOrCreate, FileAccess.Write); archive.SaveTo(fs_scratchPath, CompressionType.LZMA); fs_scratchPath.Close(); //archive.AddAllFromDirectory(SCRATCH_FILES_PATH); //archive.SaveTo(scratchPath, CompressionType.Deflate); using (FileStream fs = new FileStream("ziphead.zip", FileMode.OpenOrCreate, FileAccess.ReadWrite)) { MyHead mh = new MyHead(); byte[] headData = mh.Create(); fs.Write(headData, 0, headData.Length); // SharpCompress.IO.OffsetStream ofs = new IO.OffsetStream(fs, fs.Position); archive.SaveTo(ofs, CompressionType.Deflate); } } //write my zipfile with head data using (FileStream fs = new FileStream("mypack.data.zip", FileMode.Create, FileAccess.ReadWrite, FileShare.Read)) { MyHead mh = new MyHead(); byte[] headData = mh.Create(); fs.Write(headData, 0, headData.Length); using (FileStream fs2 = new FileStream(scratchPath, FileMode.Open, FileAccess.Read)) { byte[] buf = new byte[1024]; int rc = 0; while ((rc = fs2.Read(buf, 0, buf.Length)) > 0) { fs.Write(buf, 0, rc); } } } // //read my zip file with head // using (FileStream fs = new FileStream("mypack.data.zip", FileMode.Open, FileAccess.Read, FileShare.Read)) { byte[] buf = new byte[1024]; int offset = fs.Read(buf, 0, buf.Length); System.Diagnostics.Debug.Assert(offset == 1024); //fs.Position = 0L; SharpCompress.IO.OffsetStream substream = new SharpCompress.IO.OffsetStream(fs, offset); ZipArchive zip = ZipArchive.Open(substream, Options.KeepStreamsOpen);//cann't read //ZipArchive zip = ZipArchive.Open(fs, Options.None); //will throw exption //ZipArchive zip = ZipArchive.Open(fs, Options.KeepStreamsOpen);//cann't read foreach (ZipArchiveEntry zf in zip.Entries) { Console.WriteLine(zf.Key); //bug:the will not none in zipfile } int jjj = 0; jjj++; } }
public static void Main(string[] args) { int timestart = Environment.TickCount; ResourceService.Init(); // Stopwatch swRead = new Stopwatch(); // swRead.Start(); // IFilePackerStrategy urobot = ResourceService.GetLib(IRQ_FileType.Robot); //byte[] strInfo= urobot.OpenFile("kaka/1.png"); //urobot.DelDir("kaka"); //swRead.Stop(); //Console.WriteLine("end:"+swRead.ElapsedMilliseconds.ToString()+" ms"); //return; // //增加文件 IFileSysPackerStrategy fps = ResourceService.GetLib(IRQ_FileType.TempLeadInRes); FileStream fsadd = new FileStream("mypack.data.zip", FileMode.Open, FileAccess.Read); byte[] buf_add = new byte[fsadd.Length]; fsadd.Read(buf_add, 0, buf_add.Length); fsadd.Close(); fps.Packer.BeginUpdate(fps); if (fps.FileExists("/test/mypack.data.zip")) { byte[] testReadBuf = fps.OpenFile("/test/mypack.data.zip"); fps.DelFile("/test/mypack.data.zip"); } fps.AddFile("/test/mypack.data.zip", buf_add, DateTime.Now);//addfile fps.AddFile("/test/dir2/mypack2.data.zip", buf_add, DateTime.Now);//addfile fps.UpdateFile("/test/dir2/mypack2.data.zip", new byte[] { 1, 2, 3, 4 }, DateTime.Now); fps.AddFile("/test2/mypack.data.zip", buf_add, DateTime.Now);//addfile fps.RenameFile("/test2/mypack.data.zip", "/test2/mypack2.data.zip"); fps.RenameDir("test", "test3"); List<string> getDirs = new List<string>(); fps.GetDirs(out getDirs); fps.Clean(); fps.AddFile("/test3/mypack.data.zip", buf_add, FileEntryInfo.DateTimeFromStr_STC("2016-01-01 12:12:12"));//addfile fps.AddFile("/test4/mypack.data.zip", buf_add, DateTime.Now);//addfile getDirs = new List<string>(); fps.GetDirs(out getDirs); DateTime dtupdate = fps.GetUpdateDate("test3/mypack.data.zip"); List<string> filenames = new List<string>(); int totalSize = 0; fps.GetFiles("test3", out filenames, out totalSize); fps.DelDir("test3"); fps.RenameDir("test4", "test"); fps.Packer.EndUpdate(fps, true); Console.WriteLine("耗时:" + (Environment.TickCount - timestart).ToString() + " ms"); Console.Read(); return; string SCRATCH_FILES_PATH = "ziptest"; // { //test //CompressionType.LZMA 10次 34175ms 242k //CompressionType.PPMd 10次 68678ms 319k //CompressionType.Deflate 10次 3006ms 428k //CompressionType.BZip2 10次 10103ms 335k //CompressionType.GZip not support //CompressionType.Rar not support //CompressionType.BCJ2 not support //CompressionType.BCJ not support Stopwatch sw = new Stopwatch(); sw.Start(); //for (int i = 0; i < 10; i++) { using (var archive = ZipArchive.Create()) { DirectoryInfo di = new DirectoryInfo(SCRATCH_FILES_PATH); foreach (var fi in di.GetFiles()) { archive.AddEntry(fi.Name, fi.OpenRead(), true); } FileStream fs_scratchPath = new FileStream("compresstimetest.zip", FileMode.OpenOrCreate, FileAccess.Write); archive.SaveTo(fs_scratchPath, CompressionType.Deflate); fs_scratchPath.Close(); } //break; //} sw.Stop(); Console.WriteLine("10time (ms):" + sw.ElapsedMilliseconds.ToString()); } string scratchPath = "ziptest.zip"; using (var archive = ZipArchive.Create()) { DirectoryInfo di = new DirectoryInfo(SCRATCH_FILES_PATH); foreach (var fi in di.GetFiles()) { archive.AddEntry(fi.Name, fi.OpenRead(), true); } FileStream fs_scratchPath = new FileStream(scratchPath, FileMode.OpenOrCreate, FileAccess.Write); archive.SaveTo(fs_scratchPath, CompressionType.LZMA); fs_scratchPath.Close(); //archive.AddAllFromDirectory(SCRATCH_FILES_PATH); //archive.SaveTo(scratchPath, CompressionType.Deflate); using (FileStream fs = new FileStream("ziphead.zip", FileMode.OpenOrCreate, FileAccess.ReadWrite)) { MyHead mh = new MyHead(); byte[] headData = mh.Create(); fs.Write(headData, 0, headData.Length); // SharpCompress.IO.OffsetStream ofs = new IO.OffsetStream(fs, fs.Position); archive.SaveTo(ofs, CompressionType.Deflate); } } //write my zipfile with head data using (FileStream fs = new FileStream("mypack.data.zip", FileMode.Create, FileAccess.ReadWrite, FileShare.Read)) { MyHead mh = new MyHead(); byte[] headData = mh.Create(); fs.Write(headData, 0, headData.Length); using (FileStream fs2 = new FileStream(scratchPath, FileMode.Open, FileAccess.Read)) { byte[] buf = new byte[1024]; int rc = 0; while ((rc = fs2.Read(buf, 0, buf.Length)) > 0) { fs.Write(buf, 0, rc); } } } // //read my zip file with head // using (FileStream fs = new FileStream("mypack.data.zip", FileMode.Open, FileAccess.Read, FileShare.Read)) { byte[] buf = new byte[1024]; int offset = fs.Read(buf, 0, buf.Length); System.Diagnostics.Debug.Assert(offset == 1024); //fs.Position = 0L; SharpCompress.IO.OffsetStream substream = new SharpCompress.IO.OffsetStream(fs, offset); ZipArchive zip = ZipArchive.Open(substream, Options.KeepStreamsOpen);//cann't read //ZipArchive zip = ZipArchive.Open(fs, Options.None); //will throw exption //ZipArchive zip = ZipArchive.Open(fs, Options.KeepStreamsOpen);//cann't read foreach (ZipArchiveEntry zf in zip.Entries) { Console.WriteLine(zf.Key); //bug:the will not none in zipfile } int jjj = 0; jjj++; } }
public virtual byte[] WriteBytes() { return(MyHead.Write()); }