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


C# FileStream.ReadContent方法代码示例

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


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

示例1: Execute

        public void Execute()
        {
            var fileName = Path.GetFileNameWithoutExtension(_file);
            var path = Path.GetDirectoryName(_file);
            if (path != null)
            {
                var output = Path.Combine(path, fileName + "_" + DateTime.Now.ToString("ddMMyyyy") + ".jpeg");
                using (var fs = new FileStream(_file, FileMode.Open, FileAccess.Read))
                {
                    var request = new JMeterLogsRequest {Logs = fs.ReadContent()};

                    var dataResultsResponse = _service.ProcessLogs(request);
                    var chartResponse =
                        _service.GenerateCharts(new JMeterDataResultsRequest { DataResults = dataResultsResponse.DataResults });
                    using (var outputStream = new FileStream(output, FileMode.Create, FileAccess.ReadWrite))
                    {
                        outputStream.Write(chartResponse.Charts[0].Data, 0, chartResponse.Charts[0].Data.Length);
                        Console.WriteLine("{0} Done", output);
                    }
                }
            }
        }
开发者ID:fdore,项目名称:jmeter-toolkit,代码行数:22,代码来源:FileCommand.cs

示例2: Execute

        public void Execute()
        {
            string[] filePaths = Directory.GetFiles(_directory, "*.jtl", SearchOption.AllDirectories);
            if (filePaths.Length > 0)
            {
                Console.WriteLine("{0} file{1} to process...", filePaths.Length, filePaths.Length > 1 ? "s" : "");
                if (_merge)
                {
                    Console.WriteLine("Creating Trend Charts...");
                    var dataResults = new List<RequestDataResults>();
                    // Process files and merge results
                    foreach (var file in filePaths)
                    {
                        using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read))
                        {
                            var dataResultsResponse = _service.ProcessLogs(new JMeterLogsRequest { Logs = fs.ReadContent() });
                            dataResults.AddRange(dataResultsResponse.DataResults);
                        }
                    }

                    // Generate chart
                    var chartResponse = _service.GenerateCharts(new JMeterDataResultsRequest { DataResults = dataResults.ToArray() });

                    // Save image
                    chartResponse.Charts.AsParallel().ForAll(chart =>
                    {
                        var fileName = string.Format(
                            "{0}_{1}.jpeg", DateTime.Now.ToString("ddMMyyyy"), chart.Name.Replace('/', '_'));
                        string output = Path.Combine(_directory, fileName);
                        if (_outputDirectory != null)
                        {
                            if (!Directory.Exists(_outputDirectory))
                                Directory.CreateDirectory(_outputDirectory);
                            output = Path.Combine(_outputDirectory, fileName);
                        }

                        using (
                            var outputStream = new FileStream(output,
                                                              FileMode.
                                                                  Create,
                                                              FileAccess.
                                                                  ReadWrite)
                            )
                        {
                            Console.WriteLine("Writing {0} ... ({1}KB)",
                                              fileName,
                                              chart.Data.Length / 1000);
                            outputStream.Write(chart.Data, 0,
                                               chart.Data.Length);
                            Console.WriteLine("{0} Done", output);
                        }
                    });

                }
                else
                {
                    Console.WriteLine("Creating Comparison Charts...");
                    foreach (var file in filePaths)
                    {
                        var cmd = new FileCommand(file);
                        cmd.Execute();
                    }
                }
            }
            else
            {
                Console.WriteLine("No file to process.");
            }
        }
开发者ID:fdore,项目名称:jmeter-toolkit,代码行数:69,代码来源:DirectoryCommand.cs


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