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


C# BZip2InputStream.CopyTo方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            // Configuration section

            string startFormat = "Directory Name";
            string endFormat = "\"";

            Console.WriteLine("Please specify a folder path that contains bz or xml filelist documents");
            string filepath = Console.ReadLine();

            // Create a new explorer process for selecting folder
            Process explorerProcess = new Process();

            // Get current user's username directory and starts
            string userProfileFolder = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);

            // Using statement explicitly ensures that the instance is disposed of properly.
            using (FolderBrowserDialog fileDialogue = new FolderBrowserDialog()) {

                // Saves the dialogue in an DialogResult instance
                DialogResult result = fileDialogue.ShowDialog();

                // Saves selected directory, and files in directory
                string fileDirectory = fileDialogue.SelectedPath.ToString();
                string[] fileArray = Directory.GetFiles(fileDialogue.SelectedPath);

                // TEMP, string of entire file
                string files = string.Join(" ", fileArray);

                foreach(string file in fileArray) {

                    // Stores the file in bzis
                    BZip2InputStream bzis = new BZip2InputStream(File.OpenRead(file));

                    // Create file at directory + txt
                    String fileName = fileDirectory + "\\temp.txt";
                    FileStream fileStream = new FileStream(fileName, FileMode.OpenOrCreate);
                    bzis.CopyTo(fileStream);

                    String fileWrite = fileDirectory + "\\finalList.txt";

                    fileStream.Close();

                    using (StreamReader sr = File.OpenText(fileName)) {

                        String line;
                        while ((line = sr.ReadLine()) != null) {

                            Regex reg = new Regex("\\B(<Directory Name=)\\B\".*?\"");
                            MatchCollection matches = reg.Matches(line);

                            // Count to see whether the directory is a subchild
                            int i = 0;
                            using (StreamWriter swr = new StreamWriter(fileWrite,  true)) {
                                foreach (var item in matches) {
                                    swr.WriteLine(item.ToString());
                                }
                            }
                        }
                    }

                    // Close
                    bzis.Close();

                    // Creates a new byte buffer, and stores the contents of the bzip into the buffer
                    //byte[] byteBuffer = new byte[bzis.Length];
                    //bzis.Read(byteBuffer, 0, byteBuffer.Length);

                    // Close the stream as we dont need it.
                    //bzis.Close();

                    /*

                    // Encode into string before returning
                    string tempBZString = bString.ToString();

                    Regex reg = new Regex("\".*?\"");
                    MatchCollection matches = reg.Matches(tempBZString);

                    using (StreamWriter streamWriterFile = new StreamWriter(fileDirectory + "\\temp.txt")) {
                        foreach (var item in matches) {
                            streamWriterFile.WriteLine(item.ToString());
                        }
                    }

                    */
                }
            }

            // Prevents the console from closing automatically, by inserting breakpoint
            Console.WriteLine("Press enter to close...");
            Console.ReadLine();
        }
开发者ID:Denvious,项目名称:filestore,代码行数:93,代码来源:Program.cs


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