当前位置: 首页>>代码示例>>C#>>正文


C# ZipFile.OfType方法代码示例

本文整理汇总了C#中ICSharpCode.SharpZipLib.Zip.ZipFile.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# ZipFile.OfType方法的具体用法?C# ZipFile.OfType怎么用?C# ZipFile.OfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICSharpCode.SharpZipLib.Zip.ZipFile的用法示例。


在下文中一共展示了ZipFile.OfType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

		public void Execute()
		{
			var tempFileName = Path.GetTempFileName();
			File.Delete(tempFileName);
			try
			{
				NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(testPort);
				using (var ravenDbServer = new RavenDbServer(new RavenConfiguration
				{
					DataDirectory = tempFileName,
					Port = testPort,
					AnonymousUserAccessMode = AnonymousUserAccessMode.All,
					RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true
				}))
				{
					using (var zipFile = new ZipFile(file))
					{
						var zipEntries = zipFile.OfType<ZipEntry>()
							.Where(x => x.Name.StartsWith("raw/"))
							.Where(x => Path.GetExtension(x.Name) == ".txt")
							.GroupBy(x => x.Name.Split('_').First())
							.Select(x => new { Request = x.First(), Response = x.Last() })
							.ToArray();

						foreach (var pair in zipEntries)
						{
							// wait until we are finished executing
							// make scenario executing predictable
							while (ravenDbServer.Database.HasTasks)
								Thread.Sleep(50);

							TestSingleRequest(
								new StreamReader(zipFile.GetInputStream(pair.Request)).ReadToEnd(),
								zipFile.GetInputStream(pair.Response).ReadData()
								);
						}
					}
				}
			}
			finally
			{
				if (Directory.Exists(tempFileName))
					Directory.Delete(tempFileName, true);
			}
		}
开发者ID:ajaishankar,项目名称:ravendb,代码行数:45,代码来源:Scenario.cs

示例2: Execute

        public void Execute()
        {
            var tempFileName = Path.GetTempFileName();
            File.Delete(tempFileName);
            try
            {
                RavenDbServer.EnsureCanListenToWhenInNonAdminContext(testPort);
                using (new RavenDbServer(new RavenConfiguration
                {
                    DataDirectory = tempFileName,
                    Port = testPort,
                    AnonymousUserAccessMode = AnonymousUserAccessMode.All,
                    ShouldCreateDefaultsWhenBuildingNewDatabaseFromScratch = false
                }))
                {
                    using (var zipFile = new ZipFile(file))
                    {
                        var zipEntries = zipFile.OfType<ZipEntry>()
                            .Where(x => x.Name.StartsWith("raw/"))
                            .Where(x => Path.GetExtension(x.Name) == ".txt")
                            .GroupBy(x => x.Name.Split('_').First())
                            .Select(x => new {Request = x.First(), Response = x.Last()})
                            .ToArray();

                        foreach (var pair in zipEntries)
                        {
                            TestSingleRequest(
                                new StreamReader(zipFile.GetInputStream(pair.Request)).ReadToEnd(),
                                zipFile.GetInputStream(pair.Response).ReadData()
                                );
                        }
                    }
                }
            }
            finally
            {
                Directory.Delete(tempFileName, true);
            }
        }
开发者ID:torkelo,项目名称:ravendb,代码行数:39,代码来源:Scenario.cs

示例3: ExtractZipForInstall

        public static async Task ExtractZipForInstall(string zipFilePath, string outFolder)
        {
            var zf = new ZipFile(zipFilePath);
            var entries = zf.OfType<ZipEntry>().ToArray();
            var re = new Regex(@"lib[\\\/][^\\\/]*[\\\/]", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);

            try {
                await Utility.ForEachAsync(entries, (zipEntry) => {
                    if (!zipEntry.IsFile) return;

                    var entryFileName = Uri.UnescapeDataString(zipEntry.Name);
                    if (!re.Match(entryFileName).Success) return;

                    var fullZipToPath = Path.Combine(outFolder, re.Replace(entryFileName, "", 1));
                    var directoryName = Path.GetDirectoryName(fullZipToPath);

                    var buffer = new byte[64*1024];

                    if (directoryName.Length > 0) {
                        Utility.Retry(() => Directory.CreateDirectory(directoryName), 2);
                    }

                    Utility.Retry(() => {
                        using (var zipStream = zf.GetInputStream(zipEntry))
                        using (FileStream streamWriter = File.Create(fullZipToPath)) {
                            StreamUtils.Copy(zipStream, streamWriter, buffer);
                        }
                    }, 5);
                }, 4);
            } finally {
                zf.Close();
            }
        }
开发者ID:jochenvangasse,项目名称:Squirrel.Windows,代码行数:33,代码来源:ReleasePackage.cs


注:本文中的ICSharpCode.SharpZipLib.Zip.ZipFile.OfType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。