Telerik Forums
Telerik Document Processing Forum
5 answers
277 views
I have a Silverlight application that is importing Shape files (.shp) and parsing them as streams.  A shape file usually also include other companion files that have the same file name other than having a different extension (such as .dbf and .prj).  

Because I want to be able to import these file groups directly or from within ZIPs, I wrote some logic to first add all the imported files to a list, then explode any imported zip files' file contents into that same list.  When I pass a ZipInputStream to my parsing logic, I get errors and strange behavior that I don't get when I import the files directly.  Here's the error I usually get:

System.IO.EndOfStreamException: Attempted to read past the end of the stream.

What am I doing wrong?  Why can't I just parse the ZipInputStreams the same way I parse the FileStreams that come from the OpenFileDialog?

NOTE: Sample project is available here.  First try importing the sample data files directly (test.shp, test.dbf, test.prj) by multi-selecting them in the OpenFileDialog.  Then, try importing the ZIP file (test.zip) which contains the exact same three files and see the error.

Thanks,
J. Tower
Falafel Support
Top achievements
Rank 1
 answered on 29 Nov 2011
3 answers
370 views
Hi

I want to be able to upload a zip file to the server (using RadUpload) and then extract the files within it to the server once uploaded.

How do i do this?

Many Thanks
Tracey
Tina Stancheva
Telerik team
 answered on 22 Nov 2011
1 answer
166 views
Hello,

I am having a lot of success with this new addition to the Telerik WPF library, however i cannot see how I can add a directory to the archive?
Thanks,

Xavier.
Tina Stancheva
Telerik team
 answered on 30 Sep 2011
1 answer
154 views
How to set password on Saving & opening the zip file.
Viktor Tsvetkov
Telerik team
 answered on 14 Sep 2011
2 answers
284 views
Good day,

      I have a code as follows to compress I just copied it from the documentation:

private string CompressString(string str)
        {
            MemoryStream memoryStream = new MemoryStream();
            ZipCompression method = ZipCompression.Default;
            ZipOutputStream zipOutputStream = new ZipOutputStream(memoryStream, method);
            StreamWriter writer = new StreamWriter(zipOutputStream);
            writer.Write(str);
            writer.Flush();
            return Convert.ToBase64String(memoryStream.ToArray());
        }


  What is missing is to decompress it, I tried the following code but it doesn't give me the correct output

private string UnCompressString(string str)
        {

            MemoryStream memoryStream = new MemoryStream(Convert.FromBase64String(str));
            ZipInputStream input = new ZipInputStream(memoryStream);
            StreamReader reader = new StreamReader(input.BaseStream);
            string strData = reader.ReadToEnd();
            return strData;

        }

  When I tried to call the uncompressstring method, it does not give me the original text.

Thanks
Levi
Top achievements
Rank 1
 answered on 07 Sep 2011
6 answers
287 views
Is there a way to unzip from the ZipPackage? My current routine is incorrect.

Here are my two routines (zip and unzip):
        public static void ZipStream(Stream oInStreamstring sFileNameStream oZipStream)
        {
            ZipPackage oZipPackage = ZipPackage.Create(oZipStream);
            oZipPackage.AddStream(sFileNameoInStream);
        }
 
        public static Stream UnzipStream(Stream oZipStreamint iIndex = 0//this is incorrect; returns zipped stream
        {
            ZipPackage oZipPackage = ZipPackage.Open(oZipStreamFileAccess.Read);
            return oZipPackage.ZipPackageEntries[iIndex].OpenInputStream();
        }
Viktor Tsvetkov
Telerik team
 answered on 09 Aug 2011
1 answer
162 views
Hello.

Does ZipLibrary of RadControls support ZIP encryption specs like AES 128?
I cannot find related description in your site.
Viktor Tsvetkov
Telerik team
 answered on 29 Jul 2011
9 answers
302 views
I'm downloading a ZIP file handler and do a verification with the ZipPackage and gives me a method not supported error

My code:
request.BeginGetResponse(result =>
                    {
                        var response = request.EndGetResponse(result) as HttpWebResponse;
                        try
                        {                           
                          //  StreamResourceInfo info = new StreamResourceInfo(response.GetResponseStream(), null);
                            //StreamResourceInfo zip = Application.GetResourceStream(info, new Uri("datos", UriKind.RelativeOrAbsolute));
                            Stream info = response.GetResponseStream();
                           
                            if (ZipPackage.IsZipFile(info))
                            {
                                using (ZipPackage zipPackage = ZipPackage.Open(info, FileAccess.Read))
                                {
                                    ZipPackageEntry zip = zipPackage.ZipPackageEntries[0];
                                    using (Stream responseStream = zip.OpenInputStream())
                                    {
                                        using (StreamReader reader = new StreamReader(responseStream))
                                        {
                                            string texto = reader.ReadToEnd();
                                            lista = JsonConvert.DeserializeObject<List<Reportes>>(texto);
                                            dis.BeginInvoke(new AddtoLista(LlenarLista), lista);
 
                                            reader.Close();
                                            responseStream.Close();
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
 
                            throw ex;
                        }
                    }, null);

Thank you very much in advance
Viktor Tsvetkov
Telerik team
 answered on 27 Jul 2011
3 answers
161 views
Hey guys, I got the following stored in a text (.txt) file, which is, of course, zipped:
Hello World!

However, if I read the file like:
ZipInputStream zis = new ZipInputStream(entry.OpenInputStream());                             
StreamReader streamReader = new StreamReader(zis);                             
String text = streamReader.ReadToEnd();

The string (text) is:
ello World!

Am I doing something wrong or is this a bug (a read() instead of a peek() somewhere)?

Thank you!
Petar Mladenov
Telerik team
 answered on 25 Jul 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?