|
ok, good people..i have a following line of code..
using( MemoryStream mStr = new MemoryStream( ) )
{
try
{
mStr.Capacity = totalByteCount ;
}
}
Of course the dude i got inherited this code from is trying to put 141372000 in the memory buffer i.e the capacity. At this point i get the following error
Exception of type System.OutOfMemoryException was thrown." }
I am at a total loss. Have tried different things...So i throw a hail mary over to the code porject dudes.
Thanks for your help
Sameer
|
|
|
|
|
Isn't it possible just use the following code:
using(MemoryStream stream = new MemoryStream()) {<br />
for(int i= 0; i < totalByteCount; i++) {<br />
stream.Write(new byte[] { 0 },0,1);
}<br />
<br />
stream.Seek(0,...);<br />
}
This simply fills the stream with zeroes and resets the stream to the beginning. This way the capacity is set to the right value automatically, plus the stream is really that size.
-- EDIT:
Hmm, I'm sleeping again I tried the code and it seems to me that you are indeed short of memory for this action.
WM.
What about weapons of mass-construction?
|
|
|
|
|
If you really need to write 141MB worth into a stream, perhaps the hard drive is a better location (i.e. FileStream) rather tha RAM memory (i.e. MemoryStream).
|
|
|
|
|
Hi, does anyone know where I can find a free graphing package or windows form control, similar to the scrolling graphs in Windows Task Manager?
I have found several by searching the net, however none seem to have scrolling graphs natively, which doesn't require modifications.
Thanks
|
|
|
|
|
I began working on my first project for a new company back in early September. When I started my project, I told my boss I would be coding in the 2.0 framework, to which he said "Great, sounds good."
So naturally, after completing my project yesterday, what did I discover? The company's servers are only compatible with the 1.1 framework because they're using IIS 5.0 on that server(IIS 5.0 can only allow 1 version of the framework for all projects as opposed to IIS 6.0 which can accomodate different framework versions for different projects). So now, I have to go back and downgrade all of my code to be 1.1 compatible.
One question I have is what's the equivalent of the "List" class(i.e. "List<string>") in version 1.1? I need to declare an array of an unknown size that can increase its elements dynamically as necessary.
Thanks.
-Goalie35
|
|
|
|
|
use arraylist
Sameer Sood
Microsoft Student partner
NIT Durgapur,india
|
|
|
|
|
ArrayList would be the quickest replacement.
If you want your code to remain type-safe, implement custom collections for each type derived from CollectionBase[^] as shown in the example.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
I want to use a font that does not come standard with windows. Is there any way that i can store the font in the app?
(I know of one way, but its not so great - copy the font file into the Fonts folder on the pc when the app loads - but by this point the font's already been replaced by the default and the user doesn't see the new font until the next time they run the app)
|
|
|
|
|
You could store it as a resource in you applications resources.
Darka [ Xanya]
"I am not a slave to a god that doesn't exist."
|
|
|
|
|
The best way to get this done, is to create a setup application which installs the font. That way you don't need to restart the application before you are able to see the font in it. Also this is prevents all kinds of weird hacks that might be needed when trying other ways of using the font
WM.
What about weapons of mass-construction?
|
|
|
|
|
Hi all,
I'd like to handle shutdown event of the operating system, from a windows service.
Anyone knows how ?
Thanks in advance...
|
|
|
|
|
|
Hi
At click event of button i call a thread.
in thread i am searching file(i.e.recursive function).
How can i know that search has ended.
|
|
|
|
|
|
May u explain this ,how to handle
|
|
|
|
|
at the end of the thread give a callback (or/and event) that will alert the main thread that the serach thread has finished
|
|
|
|
|
How to get programatically list of application currently opened in operatin system?
|
|
|
|
|
using System.Diagnostics;
...
Process[] aProc = Process.GetProcesses()
This will give you the currently opened applications...
|
|
|
|
|
Hi All,
While working with plotting in EMF format i am getting a strange problem. On executing the C# code that creates a Graphics object for metafile, the EMF automatically gets deleted as after all processing,the metafile Graphics object is disposed. If we don't dispose, then the metafile created is somewhat corrupted as none of the viewer opens it. Actually i am plotting a display by drawing lines. When i plot more then 2500 such lines, this scenario occurs. Why is this happening?Is there any workaround for this?
Thanks in advance,
Regards
Chandra
|
|
|
|
|
Hi All,
I am looking for plotting support in C#. I am working with EMF(Enhanced metafile) files. My application can send the output to an EMF file but alternatively, i want to have some mechanism to send the output directly to plotter. On similar pattern to as .Net provide some API's for printing , are there any API's available in .Net or some third party API's available for plotter?
Thanks in advance,
Regards
Chandra
|
|
|
|
|
Hi
I am developing an application for making data flow diagrams in c#, i can move around objects and also draw lines from one point to another, but the problem is that once the lines are drawn and then i move other objects around the lines get erased for obvious reasons how to get rid of that?
Sameer Sood
Microsoft Student partner
NIT Durgapur,India
|
|
|
|
|
That is because you are drawing on the screen where the control happens to be instead of using the control to do the drawing.
Use the Paint event of the control to do the drawing. Then whenever the control has to be redrawn for any reason, the lines will also be redrawn.
Store the coordinates of the lines to draw in a list or something. Add coordinates to the list and use the Invalidate method on the control to make it redraw itself.
---
b { font-weight: normal; }
|
|
|
|
|
i knw that and i hv done it
the problem is that it's a reversible line and this is done using controlpaint. this line is drawn only w.r.t. a form and not a control as far as i kinw, so hw to do that, to make it simple let us say u re drawing a line like mspaint, hw to handle that sort of line?
Sameer Sood
Microsoft Student partner
NIT Durgapur,india
|
|
|
|
|
plz dnt us txtspk in 4rm, it mks psts v.hrd 2 rd
|
|
|
|
|
If "u" "hv" done it that way, what is the problem? Whenever a part of the form needs repainting, it will first draw it's background, then "ur" event handler for the Paint event will draw the lines on top of it. It doesn't matter how "u" draw the lines, as they will always "b" drawn from the same state.
If "u" "re" drawing a line like mspaint, "u" "wd" "b" drawing it on a bitmap, then displaying the bitmap.
---
b { font-weight: normal; }
|
|
|
|