Compressing Memory Streams?

Jun 24, 2009

I have this code for compressing datasets into files:

Using fs As New System.IO.FileStream(flnm, IO.FileMode.OpenOrCreate, IO.FileAccess.Write, IO.FileShare.Write)
Using zStrm As New System.IO.Compression.GZipStream(fs,

[code].....

View 1 Replies


ADVERTISEMENT

VS 2010 Working With Streams?

Mar 23, 2012

I am serializing and deserializing a class - and sending it around with httplisteners - code looks like this Dim inputstream As Stream = request.InputStream()Deserialize(FSOb, inputstream)With the Deserialize function looking like this (and the Serialize as well - it deals with a memorystream)

Public Sub Deserialize(ByRef FSOb As FSObject, ByRef st As Stream)
Dim bf As New BinaryFormatter()
FSOb = CType(bf.Deserialize(st), FSObject)
End Sub

[Code]...

View 5 Replies

.net - Overlays Using Streams Resizes An Image?

Dec 28, 2009

I found that the overlay function was working fine. However, it seems that if I use the overlay function while reading an image from a stream, that it would enlarge the picture before overlaying it.

ie:

overlay = New Bitmap(stream)
g.DrawImage(overlay, 0, 0)

Seems to enlarge the image before overlaying it, whereas this:

overlay = New Bitmap(My.Resources.Pic)
g.DrawImage(overlay, 0, 0)

Seems to overlay the image fine.

What could be the reason for this?

View 1 Replies

Feeding A Listbox With A Stream - New To Streams From VB6?

Dec 20, 2011

I am new to .NET from VB6. So I do not have any background with streams, however the concept seems straight forward. I am trying to populate a listbox using the ADD method with the data originating in a text file. Using a stream reader I am aquiring the data (I can prove that the data is there at every itteration using the debugging tools). However, it doesn't make it into the listbox. I have other data appear withn the listbox in a couple of different ways just to prove that there is nothing wrong with the way the listbox is setup or coded. The listbox is a single instance item on a form, all setup is done through the properties window.

[Code]....

View 7 Replies

Compressing RTF For Database

Aug 22, 2011

I am developing an application where the user saves a chosen RTF file to a SQL Server database. My problem is that if the file contains an image, the binary becomes too big. Although the database has enough space, it's not very nice to use up space you could save.... To give an example:

[Code]...

View 2 Replies

Compressing RTF For Database?

Aug 22, 2011

I am developing an application where the user saves a chosen RTF file to a SQL Server database. My problem is that if the file contains an image, the binary becomes too big. Although the database has enough space, it's not very nice to use up space you could save....To give an example:

RTF binary with two text lines ("ABC / efg") = 156 Bytes
Same 2 lines + 32 kB image = 2.2MB

I am still confused on which is the best way to solve this. I have thought about creating an "images" table in my database and using a markup to fetch the image when the file is loaded.

View 8 Replies

Consume A StreamReader Stream .NET From A Web Request As It Streams?

Nov 12, 2011

I experimenting with the Twitter streaming api, an am trying to open a stream for a user to consume events as they happen. I using a standard set of classes for making REST api calls to twitter. When using url... in a "GET" call the response stream never ends.I'm opening a StreamReader and reading the response as I would with any other REST call to Twitter. This is probably obvious to others, but how do I "consume" this stream... Is there a way to read the StreamReader as it's reading (meaning before it closes)? or maybe there a different method I can user to consume this stream.... again, I apologize if this seams to be elementary to some, but I can't figure it out at the moment. Here is the original source I started troubleshooting this with.This method was fabricated from a set of C# Classes I found in a forum on LinkedIn. At the line that reads "responseData = responseReader.ReadToEnd()" the method starts to "drink" the stream... but do so like a bottomless cup... reading this stream of data in real time before it closes (which is essentially until I stop debugging or kill the process) is the question I'm tackling.[code]

This write the opened twitter stream to the file, and every time I Tweet, Retweet, Delete, Direct Message... and so on.The file grows with a JSON object appended to the text. I used the Do While 0 < 1 for testing here, because I just wanted to see it working. I see on MSDN StreamReader Constructor Description that the New constructor is supposed to accept a Boolean value for "leaveOpen", but no such argument allowed when I try to add this to the constructor.Does anyone have a good example of how to do this with forcing and infinite loop or just a better approach than this... I would like to simply read new updates sent each time from Twitter, and address them accordingly? There is obviously a way, I'm just new to the concept of consuming a stream like this with out it being closed.

View 2 Replies

Create Streams Of Images To Be Viewed In Browser?

Aug 16, 2010

I want to be able to take snapshots of the desktop periodically(about 1 every 300 ms) then be able to view them live through a web browser.

Here is what I already have:

I already have a form which takes the snapshots, overwrites a file called 1.jpg with the image. I also already have an http server running which succesfully serves up html documents.[code]...

View 1 Replies

Files And Streams - View And Search For Record

Apr 18, 2010

I build an application that has two forms; one gets an employee info and stores in on a txt file (I accomplished that) and the other for viewing the records and searching for a record. I'm having troubles with viewing the records one by one when I click on the "Next Record" button.

The code below is only for view form
vb.net
Imports System.IO
Public Class frmView
'Dim strFilename As String
[Code] .....

View 11 Replies

C# - Worth Compressing The ViewState?

Nov 16, 2010

I agree that the best way to shorten the ViewState is to disable it on the ASP.Net controls that don't need it. Keeping it small from the beginning is a great habit.I have also heard that it is already compressed (although can be true... there are ways of compressing it even more, has described in this Stack Overflow question).

My question here is not if it should be compressed... is: when should ViewState be compressed?If we have a ViewState of 410 characters it will weight 410 bytes in a page, while a ViewState of 13.843 characters equals 13.5 KB.

13.5KB is a considerable weight already. And if I compress a CSS file that height 10KB, I think it is also worthy compressing a ViewState of 13.5KB, even if that means a little extra "thinking" on the server.

But is 410 bytes of ViewState worth the extra processing on the server?At what point is it worth compressing?

View 2 Replies

CGZIPLibrary.dll Not Compressing Files?

May 27, 2011

I am using CGZipLibrary.dll in my code for zipping the files. A .zip file is being created but the file is not getting compressed. The original file and the .zip file are of same size.

View 1 Replies

Compressing A Stream Rather Than A File?

Apr 3, 2010

I've downloaded ZLIB.NET from here and the example VB.NET code they provide works fine. It's very short so I'll paste it here for reference:

vb
Public Shared Sub CopyStream(ByRef input As System.IO.Stream, ByRef output As System.IO.Stream)
Dim num1 As Integer

[Code]...

Note that the CopyStream() subroutine is identical. The problem is that although decompressing seems to work fine, compressing does not. If I take a byte stream, compress it and then decompress it using the above code, I get a truncated version of the original stream (as an example, a 360485 byte stream becomes 311518 bytes). The resulting bytes match the original stream up until the point where it's cut off.

The only information I can find about streams being truncated is due to missing stream.Flush() commands but the output stream is flushed in the CopyStream() subroutine.

View 5 Replies

Compressing Multiple Sub Folders?

Oct 26, 2011

I've written a backup utility for one of our applications; this process involves coping sub directories of a specified base folder and an unknown number of folders within folders. I've got the process down to copy the files and directories pretty easily but I want to compress the folder structure to keep the space needed as small as possible.I've found a few utilities that work well for getting the files from the specified base folder but not any of the folders that exist in the specified start directory.The one utility I found required me to recursively search directories for the variably named directories and I am hoping for a simple switch that can be used that says base folder/file and sub directories.

View 1 Replies

Compressing Sql Server Data Across Vpn?

Aug 16, 2009

compressing sql server data (on the fly) from a select statement when accessed across the internet. i.e data is stored in Sql Server Express on a remote computer (1) connected via an Internet VPN. An application on a remote computer (2) on the same VPN sends a select statement to the SQL server machine.The data would then be compressed at computer (1) sent across the VPN and decompressed at computer (2)

The Reason is, broadband speeds are not the greatest in Australia, and it would reduce the size of the data transmitted, resulting in faster response, as the compression/decompression is done at each machine

View 1 Replies

Compressing A Database To A Single File?

Jun 4, 2010

In my contact manager program I have been storing information by reading and writing comma delimited files for each individual contact, and storing notes in a file for each note, and I'm wondering how I could go about shrinking them all into one file effectively. I have attempted using data entry tools in the visual studio toolbox and template class, though I have never quite figured out how to use them. What would be especially convenient is if I could store data as data type IOwner (a class I created) as opposed to strings.

I'd also need to figure out how to tell the program what to do when a file is opened (I've noticed in the properties how to associate a file type with the program though am not sure how to tell it what to do when it's opened).

Edit:

How about rephrasing the question: I have a class IContact with various properties some of them being lists of other class objects. I have a public list of IContact. Can I write Contacts as List(Of IContact) to a file as opposed to a bunch of strings?

Second part of the question: I have associated .cms files with my program. But if a user opens the file, what code should the program run through in an attempt to deal with the file? This file is going to contain data that the program needs to read, how do I tell it to read a file when the program is opened vicariously because the file was opened?

View 2 Replies

Compressing Normal Files Into A EXE Created By VB?

Apr 2, 2009

I am need of creating a windows executable that contains a compression of certain other binary files, (executables etc)

It is a basic form with a button, on press of the button, it has to decompress certain binary files( some other executables too) into a certain path, the decompression happens based on some specific conditions and not always., This is the reason I could not use WinZIP to create the EXE.

View 3 Replies

Selecting From Multiple Audio Streams Within A Video File Using Directshow?

Feb 21, 2009

am programming a media player in VB.Net using the Microsoft.DirectX.AudioVideoPlayback namespace. I would like to be able to play video files which have multiple audio streams (eg. several languages or commentary) and select which audio stream to play. As far as I can tell the Video and Audio classes don't provide this functionality.

View 1 Replies

Use Safe File Handles To Access Alternate Data Streams?

Dec 15, 2009

I have written a simple module to access NTFS Alternate Data Streams (ADS), which looks like this:

Imports System.IO
Module Module_ADS ' Alternate Data Streams
Private Const GENERIC_ALL As Int32 = &H10000000

[code]....

View 2 Replies

Storing Files Into An Application Compressing Them And Then Extracting Them?

Apr 8, 2009

How could I go about doing this if I can? Storing files into an application compressing them and then extracting them?

View 1 Replies

VS 2008 Compressing / Decompressing Entire Folders

Apr 1, 2010

How do you do it? I've looked it up everywhere and failed to find anything. If there is a previous post I missed that discussed this, post it as a comment and forgive me. <scenerio>Friend and I are working on a VB project. We want to export and inport folders of information, and to do so neatly, we wanted to compress the files in the format we made for our program, then be able to decompress it within the program as well. If theres any other way to do this without compression and decompression

View 2 Replies

Streaming Files - No Dialog - Streams Relatively Large Documents From A Webservice To A Proxy (Web Site)

Aug 2, 2011

I have a system which needs to be secure which streams relatively large documents from a webservice to a proxy (Web site) whch then grabs the stream and pushes this to the client. This works but there are some issues where it seems the response is not being pushed until the entire stream is complete? whether this is the case Im not sure have run charles and until it completes it is "Waiting for response".

The documents are currently PDF but it needs to handle many other types for the future. The octet stream etc is mostly testing related, how to get the Dialog to show - saying save as? for the large files the little ones don't matter to much but the big ones leave a big waiting period with no response.

Dim IncomingResponse As HttpWebResponse = DirectCast(Request.GetResponse(), HttpWebResponse)
Dim IncomingStream = IncomingResponse.GetResponseStream()

Dim BufferSize As Integer = 65536
Dim Buffer(BufferSize) As Byte

[code].....................

View 1 Replies

VS 2005 - Compressing A Dataset Converted To XML Using The GZipStream Class Added In 2.0

Mar 25, 2009

I am compressing a dataset converted to XML using the GZipStream class added in 2.0. There are a few things bothering me about this. Here's the code I am using to decompress the XML file:

Using inFile As New System.IO.FileStream(flnm, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
Dim zStrm As New System.IO.Compression.GZipStream(inFile, IO.Compression.CompressionMode.Decompress)
Dim buff(999) As Byte

[CODE]...

This seems inordinately awkward, as I am taking the stream, reading it out into byte buffers, then writing those byte buffers to a memory stream that is then passed to the dataset.ReadXml() method. The reason for this seems to have to do with what is happening in the line colored red. That line is adding a closing > onto the end of the stream. Without that, ReadXml complains about an unclosed dataset. I found out that the > was missing by writing the stream into a string and pasting the string into WordPad. Without that missing >, it appears that I wouldn't need to be using that memory stream at all, and could simply pass in the GZipStream to ReadXML, but as far as I can tell, it's impossible to look at the GZipStream to be sure that the > is not there, and it may be impossible to add it (I haven't tried).

So why is the > missing? Here's the code used to create the file that is being read into the filestream in the above

VB Using ms As New System.IO.FileStream(flnm, IO.FileMode.OpenOrCreate, IO.FileAccess.Write, IO.FileShare.Write)
Dim zStrm As New System.IO.Compression.GZipStream(ms, IO.Compression.CompressionMode.Compress)

ds.WriteXml(zStrm, XmlWriteMode.WriteSchema)
End Using

The real kicker to all of this is that while I was dissecting the first chunk of code, I added a line to check for cnt<1000. My intention was to see the last buffer that was being written into the memory stream to see whether the final > was actually there, or not. To my surprise, I reached the cnt<1000 twice. That means that one read did not read a full 1000 bytes, but read only 675. The next three or four reads were a full 1000 bytes, then the final read was just a few hundred bytes. It is my understanding that Read will return a full buffer if there are that many bytes left to read, and there were, so why did it return only a partial buffer? That suggests that there might be a hole in my XML, though with a half meg file, it's a bit much to read through it looking for something missing. However, the XML that was returned was turned into a dataset that I then merged into some existing data using code that has been working with uncompressed XML files, and I got an error that I should never have received. That may indicate that the XML was, in fact, missing something, though I will have to study the matter further to figure out whether or not that is the case. My major question has to do with the missing '>' at the very end of the file.

View 2 Replies

Loading An Image From A Jpeg That Exists In Memory (but Not On Disk) Using Direct Memory Access

Nov 5, 2009

In VB 2005, I am calling a C++ DLL function that returns the address in memory and size in bytes of a jpeg image. How can I load that jpeg image directly from memory into a picture box in my VB form? I cannot afford to save it to disk first.

View 10 Replies

Attempted To Read Or Write Protected Memory / Often An Indication That Other Memory Is Corrupt

May 22, 2007

Im getting a problem with one of my programs I have made in visual basic.NET where it gives me a memory error when i debug the program in the IDE. the exact error is this: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt". My program basically has a few forms with text fields on that get their text values from an access database on the same hard drive. Im wondering if im doing something wrong because my program just seems to eat up memory whenever it does anything. For example I have one form that has a combobox on it and when you change the drop down list selection it retreives a few strings from the database and puts them into the relevant text boxes, if you keep changing the selection then the memory usage (in task manager) just keeps going up and up. occasionally I get the error mentioned above when debugging but in my built version of the program it throws an exception everytime the memory usage gets past 49K.

Also I noticed when debugging in the "immediate window" frame I get the following message often:A first chance exception of type 'System. Invalid OperationException' occurred in System.Data.dll...Do I need to somehow be "releasing" the memory that is used to gather data once it becomes redundant?

View 12 Replies

Attempted To Read Or Write Protected Memory. This Is Often An Indication That Other Memory Is Corrupt

Nov 24, 2011

I am using the following code

This error occurs :

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Public Class FormRegEnumValue

[CODE]......................

View 2 Replies

Attempted To Read Or Write Protected Memory. This Is Often An Indication That Other Memory Is Corrupt?

Feb 1, 2009

QuoteSystem.AccessViolationException was unhandled Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt." Source="System.Windows.Forms"

Im designing a web browser and i continue to receive this error after going to about 3 websites it crashes with that error.

View 6 Replies

Necessary To Detach Event Handlers To Ensure That Memory Is Cleaned Up And That There Are Not Memory Leaks?

Jan 20, 2010

I have a BackgroundWorker object that I instantiated to perform a DB process on a background thread ansynchronously. I have event handlers for DoWork and RunWorkerCompleted. I can tell that the BackgroundWorker is disposing of itself because I added a message box into the Disposed event handler.Is it necessary to detach the event handlers to ensure that the memory is cleaned up and that there are not memory leaks?

View 1 Replies

Thread And Memory Leaks - Memory Usage Jumps About 1000k And It Never Goes Back Down

Apr 17, 2011

I've noticed that every time I start a new thread in my program, the memory usage jumps about 1000k and it never goes back down. I have ensured that the thread is no longer running, and only one instance of my worker thread is ever running at a time. I am using ThreadPool.QueueUserWorkItem and ASyncOperation to get stuff done. The program starts using a Sub Main in a module that uses STAThread; I read that using STAThread instead of MTAThread makes it impossible for the Garbage Collector to get in and consider objects for garbage collection. However, when I change the STAThread to an MTAThread, the WebBrowser control in my frmMain cannot be instantiated.

I get this exception:

Code: An unhandled exception of type 'System.Threading.ThreadStateException' occurred in System.Windows.Forms.dll

Additional information: ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment. I do threading with the WebBrowser control, so will using MTAThread fix my problem? If so, how should I partition my code so that the WebBrowser control won't be affected by the above exception? I call the thread repeatedly with a timer (although only one instance ever runs at a time), and my program's memory usage starts at about 5000k and can jump to 300,000k+ depending on many times the thread needs to be called.

View 6 Replies

2008 Express Edition: Attempted To Read Or Write Protected Memory, This Is Often An Indication That Other Memory Is Corrupt?

May 27, 2009

I cannot use Visual Basic 2008 at all. When I go to "new project" and choose "Windows Form Application" I get this error.I have tried multiple uninstall/reinstall with no result.A microsoft reply to this suggested that I needed: " .NET Framework 2.0 Service Pack 1 " I checked, and I did not have the .netframework 2.0 service Pack 1.
When I tried to download and install the above from Microsoft.com, the istaller said that "it was not allowsed" and I was not able to install the service pack 1.

I tried Uninstalling net framework 3.5, 3.0, 2.0 and then reinstalling .netframework 2.0 sevice pack 1; then reinstalling Visual basic 2008 express edition. At the reinstall of Visual basic 2008, .netframework 2.0 sevice pack 1 is unistalled by .net framework service pack 2.When I check the foruims for simiar problems, the formus are mostly for Visual basic 5.0, or other programs that I do not have.

Here is the programs I have installed:

Operating system: Windows XP
Microsoft .net framework 1.1
Microsoft .NET framwork 1.1 Hotfix(KB928366)
Microsoft .Net Framework 2.0 Service Pack 2

[code]....

All the security updates and hotfixes for Widows XP.

View 4 Replies

DirectoryEntry Memory Leak - Gets A Out Of Memory Error In The Last Catch Statement?

Jan 11, 2012

The follow code can be called about 6K times on the server it is run on then gets a out of memory error in the last catch statement. I don't see what is wrong with the code, it works well up until the out of memory..

Public Function AddUserToGroup(ByVal sSamAccountName As String, ByVal sGroupName As String) As Boolean
Try
Dim returnStatus As Boolean = True[code]......

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved