Click here to Skip to main content
16,006,442 members
Home / Discussions / C#
   

C#

 
GeneralRe: Viewing XML in AxSHDocVW Pin
Stephane Rodriguez.11-Mar-03 11:20
Stephane Rodriguez.11-Mar-03 11:20 
QuestionDraw image with alpha blending ? Pin
Wizard_0111-Mar-03 8:54
Wizard_0111-Mar-03 8:54 
GeneralGetting AVI's into a C# Windows Form project Pin
antoine@orchus-tech11-Mar-03 7:38
antoine@orchus-tech11-Mar-03 7:38 
GeneralUsing MemoryStream instead of FileStream problem Pin
LongRange.Shooter11-Mar-03 7:23
LongRange.Shooter11-Mar-03 7:23 
GeneralRe: Using MemoryStream instead of FileStream problem Pin
leppie11-Mar-03 7:38
leppie11-Mar-03 7:38 
GeneralRe: Using MemoryStream instead of FileStream problem Pin
LongRange.Shooter11-Mar-03 9:07
LongRange.Shooter11-Mar-03 9:07 
GeneralRe: Using MemoryStream instead of FileStream problem Pin
leppie11-Mar-03 10:27
leppie11-Mar-03 10:27 
GeneralRe: Using MemoryStream instead of FileStream problem Pin
LongRange.Shooter12-Mar-03 7:13
LongRange.Shooter12-Mar-03 7:13 
Ahhhh -- we found the issue. The trouble is that the MemoryStream is not like most streams in that it does not have a reader and a writer. This makes it a bi-directional stream. Eek! | :eek: As such it does not rewind itself for a read after a write. You must specify the position in the stream you want to read from or write to. So we created a read method and a write method to get it to work. Thus the final product is:

<br />
		public static byte[] ZipFilesToMemory(string dirPath,string searchPattern,<br />
  bool recursive, DateTime 				dateFilter, string basePath)<br />
		{<br />
			MemoryStream m=new MemoryStream();<br />
			ZipFile zf=new ZipFile(m,ZipFileOpenMode.Write);<br />
			zf.BasePath=basePath;<br />
			int ret=zf.Add(dirPath, searchPattern, recursive, dateFilter);<br />
			zf.ZipOutputStream.Finish();<br />
			byte[] buf = new byte[m.Length];<br />
			m.Position=0;<br />
			m.Read(buf,0,(int)m.Length);<br />
			zf.CloseZipFile();<br />
			return buf;<br />
		}<br />
<br />
		public static int ExtractFromMemory(byte[] zipBuffer,string targetPath)<br />
		{<br />
			MemoryStream m=new MemoryStream();<br />
			m.Write(zipBuffer,0,zipBuffer.Length);<br />
			ZipFile zf=new ZipFile(m,ZipFileOpenMode.Read);<br />
			int cnt=zf.Extract(targetPath);<br />
			zf.CloseZipFile();<br />
			return cnt;<br />
		}<br />


BTW -- we are using the GNU Open Source Zip streams in .NET.

_____________________________________________
The world is a dangerous place.
Not because of those that do evil,
    but because of those who look on and do nothing.

GeneralRe: Using MemoryStream instead of FileStream problem Pin
leppie12-Mar-03 8:32
leppie12-Mar-03 8:32 
GeneralAccessing controls of one form from another form Pin
Mazdak11-Mar-03 6:57
Mazdak11-Mar-03 6:57 
GeneralRe: Accessing controls of one form from another form Pin
Zek3vil11-Mar-03 7:07
Zek3vil11-Mar-03 7:07 
GeneralRe: Accessing controls of one form from another form Pin
Mazdak11-Mar-03 7:33
Mazdak11-Mar-03 7:33 
GeneralRe: Accessing controls of one form from another form Pin
Zek3vil11-Mar-03 21:13
Zek3vil11-Mar-03 21:13 
GeneralRe: Accessing controls of one form from another form Pin
Mazdak12-Mar-03 6:34
Mazdak12-Mar-03 6:34 
GeneralUpdate does not work for dataset Pin
Marix11-Mar-03 4:39
Marix11-Mar-03 4:39 
GeneralRe: Update does not work for dataset Pin
leppie11-Mar-03 6:24
leppie11-Mar-03 6:24 
GeneralRe: Update does not work for dataset Pin
Marix11-Mar-03 21:47
Marix11-Mar-03 21:47 
GeneralRe: Update does not work for dataset Pin
Marix12-Mar-03 1:44
Marix12-Mar-03 1:44 
GeneralRe: Update does not work for dataset Pin
leppie13-Mar-03 10:11
leppie13-Mar-03 10:11 
GeneralC# pipe example Pin
Davy Mitchell11-Mar-03 3:39
Davy Mitchell11-Mar-03 3:39 
GeneralCopying NOT Moving a Directory!!!! Pin
jesus4u11-Mar-03 3:13
jesus4u11-Mar-03 3:13 
GeneralRe: Copying NOT Moving a Directory!!!! Pin
Stephane Rodriguez.11-Mar-03 3:43
Stephane Rodriguez.11-Mar-03 3:43 
GeneralRe: Copying NOT Moving a Directory!!!! Pin
jesus4u11-Mar-03 3:48
jesus4u11-Mar-03 3:48 
GeneralRe: Copying NOT Moving a Directory!!!! Pin
Stephane Rodriguez.11-Mar-03 4:09
Stephane Rodriguez.11-Mar-03 4:09 
GeneralRe: Copying NOT Moving a Directory!!!! Pin
jesus4u13-Mar-03 1:49
jesus4u13-Mar-03 1:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.