|
As Judah said, it uses a new array that typically doubles whenever the Capacity is reached.
To note, the ArrayList is used internally by many collections, so don't think you can escape it so easily!
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank both of you.
I have another little question. What is the perforamce loss due to the type casting of array list elements. If my array list contains the same type elemets (or which share the same base class), could i use something equivalent to templates in C++.
Thank again.
Anton.
|
|
|
|
|
An ArrayList stores object s, so if you add reference types to the list, there's really no performance hit (1 to 2 extra instructions are required to cast, and optionally store, your type, but that's negligible). If you store value types, there is a slight performance hit because value types must be boxed and unboxed to store as an object . This is one of many reasons why generics will be great to have in the upcoming .NET Framework 2.0. Then you can declare a new list of value types, like List<int> ints = new List<int>(); .
This (un)boxing is typically not too big a problem if you don't use it a lot and don't need to milk your app for performance for every last drop. If you do, then you might consider implementing your own ArrayList -like class, implementing all the same interfaces (for the best support) and keep an array of whatever value type you need. Grow it when needs be, just like the ArrayList would.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
In this case i will keep it, since making changes later would be much easier.
Thank you.
|
|
|
|
|
I have several images that have text on them, they are instructions that were turned into jpegs. Here is the question is there a way to de-construct the image so I can get just the text?
The reason for this insanity is reports. I have a report that "could" have lots of image data and as we all know there is no good way to split an image for a page break. Is there a good way to do this?
I will be coding for IE 6 only as this is an internal project, so x-browser solutions are not required .. but always welcome..
Any help on this would be great.
Thanks
William O'Malley
|
|
|
|
|
|
thank you for the article reference. very interesting stuff.
How ever I really don't have the money to spend on a third party add in. I was really hoping that I could find a way to do this with out using a third party add-in
thanks
William O'Malley
|
|
|
|
|
You don't need third-party software: the article describes how to create your own OCR scanning solution. However you implement, the concepts around OCR are your solution.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi,
i use cards.dll to draw cards in my app.
and it works good in onpaint method
for example:
<br />
Graphics x = e.Graphics;<br />
<br />
hdc = x.GetHdc();<br />
x.ReleaseHdc(hdc);<br />
cardHandle.drawCardBack( hdc, 90, 10, eBACK.WEAVE1 );<br />
but if i try do the same thing offscreen, it does not work!
can someone explain why?
<br />
Bitmap offScreenBmp = new Bitmap(this.Width, this.Height); <br />
Graphics offScreenDC = Graphics.FromImage(offScreenBmp); <br />
<br />
hdc = offScreenDC.GetHdc();<br />
offScreenDC.ReleaseHdc(hdc);<br />
cardHandle.drawCardBack( hdc, 90, 10, eBACK.WEAVE1 );<br />
e.Graphics.DrawImage(offScreenBmp, 10, 10);<br />
I need it to rotate this card.
I have tried this method, but it does not worke.Graphics.RotateTransform(90f);
if u know another way how to rotate the card i draw with cards.dll, please tell me
thank u
|
|
|
|
|
It probably doesn't work because you're releasing the HDC before you use it. Release it afterward. Once you've drawn to an off-screen bitmap, you should have no problems rotating it.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
oh, u r right, it works!
but, what's about this first example?
it seems as if it works pretty good!
|
|
|
|
|
Surprising that it does, but you really shouldn't release the HDC until you're done (that's how it supposed to work).
See the native CreateCompatibleBitmap API. You probably need to create a bitmap that is compatible (i.e., supports the same capabilities) with the on-screen bitmap, which is usually the case in GDI. You might be able to accomplish this by using Graphics.FromHdc to get a Graphics object, then use Clone to clone it. I've never tried it this way, but GDI+ is usually as simple as this.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I need to know what is the fastest and most efficient way to upload large files (4mb to 50mb) from a c# windows form app to a win2k server. I've run into memory issues on my server with files larger than about 8m (iis caches the entire file uploaded as a byte array before writing to disk ... this causes the server to hang) and need to implement a solution to this problem.
I've fished around for a chunking solution (send the file up in, say, 500k chunks and rebuild the file on the server) but cant find any code examples on how to do this.
Any help would be greatly appreciated.
Rob
(first time poster, long time reader )
|
|
|
|
|
Sorry, but what's wrong with the System.IO.File.Copy method?
I see dumb people
|
|
|
|
|
The upload is from a windows form application to a win2k server over the internet, so its not a simple file copy over an internal lan.
|
|
|
|
|
See the class documentation for the HttpFileCollection class. You can use a simple HttpWebRequest to get the request stream and write one or more files using multipart-MIME to a Page (.aspx file). This is receieved as an HttpFileCollection which you can use to write each individual file to disk. This is a byte-for-byte copy.
If you're using Web Services or .NET Remoting, you can use DIME, for which more information can be found at http://msdn.microsoft.com/library/en-us/dnservice/html/service01152002.asp[^]. This is much faster than sending encoded byte[] arrays using SOAP.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
DIME is not an option given some of the client computers are win98.
I did some preliminary investigation into remoting and read somewhere about remoting being faster for small binary file transfer than SOAP but poor for large files ...
(btw i thought DIME used SOAP and not .net remoting ...?)
Thanks all for your speedy replies ... way faster than any of my newsgroup posts!
Rob
|
|
|
|
|
Neither DIME nor SOAP uses .NET Remoting - .NET Remoting (and Web Services) use DIME and/or SOAP (Remoting can also use other formatters).
While DIME is related to SOAP in that it's a solution to a problem, it's not really tied to it. DIME is simply prepending the actual bytes to the SOAP message and referring to it in the SOAP message body.
I'm not sure where you got that DIME doesn't work with Win98/ME. If the implementation requires it for some functionality, nothing's stopping you from implementing it yourself without such a requirement (which I've never seen, BTW). DIME is a specification. The WSE (Web Service Enhancements) supports it, but you can make your own implementation. There's plenty of conceptual and technical documentation on it, including the specification itself (don't remember where, but it'll be linked in various articles - probably on W3C[^]).
Also, if all you're doing is uploading files to a web server, you could always just stick with simple HTTP POST. It's easy. If you are needing this for a Web Services or .NET Remoting, you could always have the page that accepts the post return a cookie (not necessarily the HTTP kind - just a token that is associated with an operation) that you pass to the WS or Remoting object that identifies the group of files (perhaps stored in a file, database, or some session- or application-level cache if using the same AppDomain for the site and WS or Remoting host).
The simple point is that you want to avoid having to encode the byte[] array because its slow (typically, base64 encoding is used but this can be changed using variousing binding flags for the SoapFormatter ). If you use a BinaryFormatter as the format to be sent across the wire, you don't have to worry about this encoding problem (and its better for any size of file - or data, for that matter, but not always desirable because of interoperability with other platforms).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Sorry ... I meant the Web Services Enhancement for .NET from Microsoft does not run on a Win98 system (2k+ or XP only)
If you could point me to where I can find infor on DIME on a Win98 box that would be great!
Interoperability is not a problem given I control both ends of the system.
BTW I did implement uploading to a multipart/form-data page from my winform client but found it killed the server when the upload size exceeded 8mb .. asp.net caches the entire file to memory before writing to disk. Thats when i began to look into a chunking solution and then thought maybe theres even a better way to fire up these files to the server ...
Thanks Heath ... you've been most helpfull ... really appreciate it!
Rob
|
|
|
|
|
Just search google for DIME. As I said before, it's a specification. If the WSE is supported on Win98 (not really surprising, especially since 98 is about to become unsupported, as will ME in the near future...though not soon enough), then you need to implement it yourself. Just use the specifications on DIME to create an impementation. I already gave you one link with conceptual information in the content and links to more resources.
ASP.NET has a request limit, which is - like most things - configurable. The <httpRuntime> element in the machine.config file has a maxRequestLength attribute that specifies the maximum size (in kilobytes) of requests. This element (and hence its settings) can be configured at the machine level (machine.config), site (/Web.config), application (Web.config), or sub-directory (same) level.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I know about the config file settings ... but when you punch it up to, say, 50mb, asp.net chokes cause it caches the entire upload to memory before writing to disk ... thats why i began exploring a chunking solution.
In any case, thanks again Heath ... you've been most helpfull!
Rob
|
|
|
|
|
Then don't use a Page derivative, use a simple IHttpHandler implementation, or the built-in .ashx support (like .aspx and .ascx handlers, only to implement a simple IHttpHandler ). Write to disk as the stream is read on the server (and don't forget good clean-up code, of course, if it fails).
Chunking is still a good idea, but there's always different solutions.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How about FTP? Probably best to get a third party component, but at least it's a well understood and well supported solution.
|
|
|
|
|
Hi Guys,
only a short question. Is there a way to scan a Text in a Textbox and Compare it with a text in a file, or even parts of a other textbox text? Would be great if anybody has a solution in source or hints.
Thanks all...
Eolus
If you want realize your dreams, you should not sleep!
|
|
|
|
|
if (textBox1.Text == textBox2.Text)
MessageBox.Show("They match!"); If you want to compare it to a file, use a TextReader to read each line and use line.IndexOf(textBox1.Text); to determine if the line contains the text in textBox1 .
Microsoft MVP, Visual C#
My Articles
|
|
|
|