Click here to Skip to main content
15,897,185 members
Home / Discussions / C#
   

C#

 
Generali need ole total collection and data type Pin
badshah20054-Apr-08 11:57
badshah20054-Apr-08 11:57 
GeneralRe: i need ole total collection and data type Pin
Rick van Woudenberg4-Apr-08 12:12
Rick van Woudenberg4-Apr-08 12:12 
Generalcompare byte array Pin
baranils4-Apr-08 11:37
baranils4-Apr-08 11:37 
GeneralRe: compare byte array Pin
MidwestLimey4-Apr-08 11:55
professionalMidwestLimey4-Apr-08 11:55 
GeneralRe: compare byte array Pin
Rick van Woudenberg4-Apr-08 11:55
Rick van Woudenberg4-Apr-08 11:55 
GeneralRe: compare byte array Pin
baranils4-Apr-08 19:42
baranils4-Apr-08 19:42 
GeneralBinaryRreader The string is prefixed with the length, encoded as an integer seven bits at a time Pin
baranils4-Apr-08 10:18
baranils4-Apr-08 10:18 
GeneralRe: BinaryRreader The string is prefixed with the length, encoded as an integer seven bits at a time Pin
KaptinKrunch4-Apr-08 10:31
KaptinKrunch4-Apr-08 10:31 
I use the following method to read files. Its pretty fast and then you could use regular expressions to find text within the returned string or what ever else you need to do with the content.

        <br />
public string DecodeFile(string fullpath)<br />
        {<br />
            if (File.Exists(fullpath) == false)<br />
                throw new FileNotFoundException();<br />
<br />
            try<br />
            {<br />
                FileStream fStream = File.OpenRead(fullpath);<br />
                byte[] buffer = new byte[fStream.Length];<br />
                int bytesRead;<br />
                bytesRead = fStream.Read(buffer, 0, buffer.Length);<br />
                fStream.Close();<br />
                fStream.Dispose();<br />
<br />
                if (bytesRead <= 0)<br />
                    throw new Exception("Empty file.");<br />
<br />
                Decoder decoder = Encoding.Default.GetDecoder();<br />
                char[] cBuffer = new char[buffer.Length];<br />
<br />
                int bytesConverted, charsConverted;<br />
                bool bCompleted;<br />
<br />
                decoder.Convert(buffer, 0, buffer.Length, cBuffer, 0, buffer.Length, false, out bytesConverted, out charsConverted, out bCompleted);<br />
                return new String(cBuffer, 0, bytesConverted);<br />
            }<br />
            catch (Exception ex)<br />
            {<br />
                throw new Exception(ex.Message);<br />
            }<br />
<br />
        }<br />


Google search lead me to this info
"Well, its not quite that simple. int.MaxValue is the most the string class
itself could handle, you are right, but since characters take up two bytes,
that many characters would go way beyond the max possible allocation. The
best theoretical high value is 2^31(or 2147483648) characters, since that is
exactly how many would fit in memory. Practially it'd be much, much smaller."

http://bytes.com/forum/thread481655.html[^]

Just because we can; does not mean we should.

GeneralRe: BinaryRreader The string is prefixed with the length, encoded as an integer seven bits at a time Pin
baranils4-Apr-08 10:50
baranils4-Apr-08 10:50 
GeneralRe: BinaryRreader The string is prefixed with the length, encoded as an integer seven bits at a time Pin
Zoltan Balazs4-Apr-08 11:16
Zoltan Balazs4-Apr-08 11:16 
GeneralRe: BinaryRreader The string is prefixed with the length, encoded as an integer seven bits at a time Pin
baranils4-Apr-08 11:35
baranils4-Apr-08 11:35 
GeneralFlops Pin
snorkie4-Apr-08 9:49
professionalsnorkie4-Apr-08 9:49 
GeneralRe: Flops Pin
Rick van Woudenberg4-Apr-08 9:57
Rick van Woudenberg4-Apr-08 9:57 
GeneralRe: Flops Pin
snorkie4-Apr-08 9:59
professionalsnorkie4-Apr-08 9:59 
GeneralRe: Flops Pin
Pete O'Hanlon4-Apr-08 10:07
mvePete O'Hanlon4-Apr-08 10:07 
GeneralRe: Flops Pin
KaptinKrunch4-Apr-08 10:09
KaptinKrunch4-Apr-08 10:09 
GeneralRe: Flops Pin
snorkie4-Apr-08 10:17
professionalsnorkie4-Apr-08 10:17 
GeneralRe: Flops Pin
Dave Kreskowiak4-Apr-08 10:13
mveDave Kreskowiak4-Apr-08 10:13 
GeneralRe: Flops Pin
Rick van Woudenberg4-Apr-08 10:25
Rick van Woudenberg4-Apr-08 10:25 
GeneralRe: Flops Pin
led mike4-Apr-08 11:11
led mike4-Apr-08 11:11 
GeneralRe: Flops Pin
Zoltan Balazs4-Apr-08 11:20
Zoltan Balazs4-Apr-08 11:20 
GeneralRe: Flops Pin
MidwestLimey4-Apr-08 12:10
professionalMidwestLimey4-Apr-08 12:10 
GeneralRe: Flops Pin
MidwestLimey4-Apr-08 12:12
professionalMidwestLimey4-Apr-08 12:12 
GeneralRe: Flops Pin
MidwestLimey4-Apr-08 12:12
professionalMidwestLimey4-Apr-08 12:12 
GeneralRe: Flops Pin
MidwestLimey4-Apr-08 12:13
professionalMidwestLimey4-Apr-08 12:13 

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.