Quantcast
Channel: sharpcompress Discussions Rss Feed
Viewing all articles
Browse latest Browse all 239

New Post: EntryStream Position and Lenght Exception

$
0
0
Hi,

For my application, I don't need to write the files into an output directory/file (as I saw in all your examples), I just need to read the current file into a string/xml and process it.

Because I couldn't find any example of using EntryStream or WriteEntryTo(Stream writableStream) method in the code examples or unit tests, I decided to make the following test.
using (Stream stream = File.OpenRead(file))
{
    using (var reader = RarReader.Open(stream))
    {
        while (reader.MoveToNextEntry())
        {
            if (!reader.Entry.IsDirectory && Path.GetExtension(reader.Entry.FilePath).Equals(".xml"))
            {
                using (var entryStream = reader.OpenEntryStream())
                {    
                  byte[] bytes = new byte[entryStream.Length];
                  entryStream.Position = 0;
                  entryStream.Read(bytes, 0, (int)entryStream.Length);
                  string result = Encoding.ASCII.GetString(bytes);
                 }
             }
        }
    }
}
This code throws two exceptions "The method or operation is not implemented." - at entryStream.Position and entryStream.Lenght.

Am I doing something wrong here? If so, can you please, provide a similar example?

Thanks!
Diana

Viewing all articles
Browse latest Browse all 239

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>