Lost Password?

Go Back   CodeCall Programming Forum > Software Development > C# Programming

Vote on your favorite hash algorithm here!

C# Programming C# (pronounced C-sharp) is a new object oriented language from Microsoft and is derived from C and C++. It also borrows a lot of concepts from Java too including garbage collection.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-10-2007, 07:15 AM
hoser2001's Avatar   
hoser2001 hoser2001 is offline
Programmer
 
Join Date: Jul 2006
Posts: 175
Credits: 0
Rep Power: 10
hoser2001 is on a distinguished road
Default .NET VS Problem, "Unexpected EOF"

Using Visual Studio 2005, C#, .NET 2.0

Code:
private void ZipAndSave(DataSet ds, DataSet ds2, string Destination) 
        { 
            ZipOutputStream s = new 
            ZipOutputStream(File.Create(Destination)); 
            s.SetLevel(9); 
            s.Password = ZPW; 


            ZipEntry schema = new ZipEntry("csMod.xsd"); 
            s.PutNextEntry(schema); 
            ds2.WriteXmlSchema(s); 


            ZipEntry data = new ZipEntry("csMod.xml"); 
            s.PutNextEntry(data); 
            ds.WriteXml(s); 


            s.Finish(); 
            s.Close(); 
        } 


fsSend = new System.IO.FileStream(Destination, 
System.IO.FileMode.Open, 
System.IO.FileAccess.Read); 
                byte[] b = new byte[fsSend.Length]; 
                fsSend.Read(b, 0, (int)fsSend.Length); 


ProcessCXML(b);//This is a function residing on server, a remote 
function... 


public void ProcessCXML(byte[] bytearray) 
                { 


                        MemoryStream ms = new MemoryStream(); 
                        ms.Write(bytearray, 0, bytearray.Length); 
                                                DataSet ds = 
LoadDataFromFile(ms); 
                                } 


public DataSet LoadDataFromFile(MemoryStream ms) 
        { 
            Stream _trSchema = null; 
            DataSet ds = null; 
            Hashtable ht = new Hashtable(); 


            int BUFFER_SIZE = 2048; 
            ZipInputStream zin = null; 
            zin = new ZipInputStream(ms); 
            zin.Password = ZPW; 


            if (zin != null) 
            { 
                ZipEntry entry = null; 
                while ((entry = zin.GetNextEntry()) != null) 
                { 
                    MemoryStream stream = new MemoryStream(); 


                    int size = BUFFER_SIZE; 
                    byte[] data = new byte[BUFFER_SIZE]; 


                    while (true) 
                    { 
                        size = zin.Read(data, 0, data.Length); 
                        if (size > 0) 
                        { 
                            stream.Write(data, 0, size); 
                        } 
                        else 
                        { 
                            break; 
                        } 
                    } 


                    stream.Position = 0; 
                    TextReader reader = new StreamReader(stream, 
Encoding.UTF8); 
                    if (entry.Name.EndsWith(".xsd")) 
                    { 
                        ht.Add(entry.Name.ToLower(), stream); 
                    } 
                    else 
                    { 
                        ht.Add(entry.Name.ToLower(), reader); 
                    } 
                } 
            } 


            if (ht["csmod.xml"] != null) 
            { 
                ds = new DataSet(); 
                try 
                { 
                    ds.ReadXml((TextReader)ht["csmod.xml"]); 
                    if (ht["csmod.xsd"] != null) 
                    { 
                        _trSchema = (Stream)ht["csmod.xsd"]; 
                        _trSchema.Position = 0; 
                        ds.ReadXmlSchema(_trSchema); 
                    } 
                } 
                catch (Exception) 
                { 
                    ds = null; 
                } 
            } 


            return ds; 
        }
This is the details of the error I get from the server:


Error in ProcessCXML: Unexpected EOF at
ICSharpCode.SharpZipLib.Zip.Compression.Streams.In flaterInputBuffer.Fill()
at
ICSharpCode.SharpZipLib.Zip.Compression.Streams.In flaterInputBuffer.ReadLeB**
yte()
at ICSharpCode.SharpZipLib.Zip.ZipInputStream.GetNext Entry()
at CSRemoteServerService.ServerImpl.LoadDataFromFile( MemoryStream
ms)
at CSRemoteServerService.ServerImpl.ProcessCXML(Byte[] bytearray)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 07-10-2007, 10:13 AM
hoser2001's Avatar   
hoser2001 hoser2001 is offline
Programmer
 
Join Date: Jul 2006
Posts: 175
Credits: 0
Rep Power: 10
hoser2001 is on a distinguished road
Default

Figured out my mistake....

Right before I load the ZipStream with the Memory Stream, I have to reset the position of the memory stream...

ms.Position = 0;


Then I can load it into the ZipInput Stream....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
.NET problem with printing a barcode honzac32 C# Programming 3 07-10-2007 03:41 PM
Microsoft .NET 3.0 Jordan General Programming 7 12-08-2006 09:18 AM
Visual Studio .NET Tips and Tricks free ebook Jordan Software Development Tools 2 09-14-2006 02:12 PM
What is .NET anyway? DevilsCharm C# Programming 4 07-31-2006 07:38 PM
.net Crane Software Development Tools 4 07-14-2006 09:50 AM


All times are GMT -5. The time now is 10:44 PM.

Contest Stats

Xav ........ 1357.94
MeTh0Dz|Reb0rn ........ 1077.71
WingedPanther ........ 919.18
marwex89 ........ 906.86
morefood2001 ........ 900.18
John ........ 890.77
Brandon W ........ 770.65
chili5 ........ 312.39
Steve.L ........ 264.99
dcs ........ 232.34

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 83%

Ads