Go Back   RunUO - Ultima Online Emulation > RunUO > RunUO Post Archive > Starbucks @ RunUO.com

Starbucks @ RunUO.com Unmoderated forum for off-topic banter, screen shots, chit-chat and things of this nature. Flames are permitted, and you can pretty much do nearly anything within reason. No advertisements.

 
 
Thread Tools Display Modes
Old 07-23-2008, 11:46 PM   #1 (permalink)
Forum Expert
 
Join Date: Jul 2003
Location: Arizona
Age: 18
Posts: 3,186
Send a message via AIM to Storm33229 Send a message via Yahoo to Storm33229
Default C# Read Lines

I need to read a text file all the way through, but I need to do it with a for-loop and not the ReadToEnd function. So how would I do this. I had my example code way back but I haven't touched C# in a long time.
__________________
Quote:
Originally Posted by Radwen
You should crush your pills and sniff them.
Storm33229 is offline  
Old 07-24-2008, 12:15 AM   #2 (permalink)
Forum Expert
 
Kiwi's Avatar
 
Join Date: Sep 2002
Location: Northeast Ohio
Age: 22
Posts: 3,178
Send a message via ICQ to Kiwi Send a message via AIM to Kiwi Send a message via MSN to Kiwi
Default

ReadLine()?
Kiwi is offline  
Old 07-24-2008, 01:04 AM   #3 (permalink)
Forum Expert
 
Join Date: Jul 2003
Location: Arizona
Age: 18
Posts: 3,186
Send a message via AIM to Storm33229 Send a message via Yahoo to Storm33229
Default

Quote:
Originally Posted by Kiwi View Post
ReadLine()?
lol no actually i figured it out
Code:
            while ((line = sreader.ReadLine()) != null)
            {
                char[] buffer1 = new char[2];
                char[] buffer2 = new char[2];
                char[] buffer3 = new char[2];
                char[] buffer4 = new char[2];
                char[] buffer5 = new char[2];
                char[] buffer6 = new char[2];
                sreader.ReadBlock(buffer1, 0, 2);
                sreader.ReadBlock(buffer2, 0, 2);
                sreader.ReadBlock(buffer3, 0, 2);
                sreader.ReadBlock(buffer4, 0, 2);
                sreader.ReadBlock(buffer5, 0, 2);
                arrayList1.Add(buffer1);
                arrayList1.Add(buffer2);
                arrayList1.Add(buffer3);
                arrayList1.Add(buffer4);
                arrayList1.Add(buffer5);
                arrayList2.Add(buffer6);
            }
__________________
Quote:
Originally Posted by Radwen
You should crush your pills and sniff them.
Storm33229 is offline  
Old 07-24-2008, 01:45 AM   #4 (permalink)
ConnectUO Creator
 
Jeff's Avatar
 
Join Date: Jan 2004
Age: 28
Posts: 4,891
Default

wtf that code is hidious and you are missing stuff since the stream moves through with ((line = sreader.ReadLine()) then reads more with the block calls. More then likely you are skipping things.
__________________
Jeff Boulanger
ConnectUO - Core Developer

Want to help make ConnectUO better? Click here to submit your ideas/requests
Use your talent to compete against other community members in RunUO hosted coding competitions

If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team.


Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO
Jeff is offline  
Old 07-24-2008, 01:48 AM   #5 (permalink)
Forum Expert
 
Kiwi's Avatar
 
Join Date: Sep 2002
Location: Northeast Ohio
Age: 22
Posts: 3,178
Send a message via ICQ to Kiwi Send a message via AIM to Kiwi Send a message via MSN to Kiwi
Default

Quote:
Originally Posted by Jeff View Post
wtf that code is hidious and you are missing stuff since the stream moves through with ((line = sreader.ReadLine()) then reads more with the block calls. More then likely you are skipping things.
Be nice Jeff EVERYONE STARTS SOMEWHERE
Kiwi is offline  
Old 07-24-2008, 02:20 AM   #6 (permalink)
Master of the Internet
 
Radwen's Avatar
 
Join Date: Apr 2005
Location: Nowhere
Age: 22
Posts: 11,653
Default

Well he did say he "figured it out". I just decided to not respond instead of being mean as he said he didn't code in a long time.
__________________
-Socks are great.

Ask Radwen.
http://www.runuo.com/forums/starbucks-runuo-com/76473-ask-radwen.html
Radwen is offline  
Old 07-24-2008, 12:05 PM   #7 (permalink)
Forum Master
 
Joeku's Avatar
 
Join Date: Feb 2005
Location: ShatteredSosaria.com
Posts: 9,260
Default

Quote:
Originally Posted by Kiwi View Post
Quote:
Originally Posted by Jeff View Post
wtf that code is hidious and you are missing stuff since the stream moves through with ((line = sreader.ReadLine()) then reads more with the block calls. More then likely you are skipping things.
Be nice Jeff EVERYONE STARTS SOMEWHERE
Hahahahaha
Joeku is offline  
Old 07-24-2008, 12:15 PM   #8 (permalink)
Forum Expert
 
Join Date: Jul 2003
Location: Arizona
Age: 18
Posts: 3,186
Send a message via AIM to Storm33229 Send a message via Yahoo to Storm33229
Default

getProbable Method
reads powerpicks txt. 2 characters at a time and adds certain readings to certain array lists.
Code:
static void getProbable()
        {
            ArrayList regNum = new ArrayList();
            ArrayList powNum = new ArrayList();
            TextReader sreader = new StreamReader(@"powerpicks.txt");
            string line;
            while ((line = sreader.ReadLine()) != null)
            {
                char[] buffer1 = new char[2];
                char[] buffer2 = new char[2];
                char[] buffer3 = new char[2];
                char[] buffer4 = new char[2];
                char[] buffer5 = new char[2];
                char[] buffer6 = new char[2];
                sreader.ReadBlock(buffer1, 0, 2);
                sreader.ReadBlock(buffer2, 0, 2);
                sreader.ReadBlock(buffer3, 0, 2);
                sreader.ReadBlock(buffer4, 0, 2);
                sreader.ReadBlock(buffer5, 0, 2);
                sreader.ReadBlock(buffer6, 0, 2);
                string buffer1b = buffer1.ToString();
                string buffer2b = buffer2.ToString();
                string buffer3b = buffer3.ToString();
                string buffer4b = buffer4.ToString();
                string buffer5b = buffer5.ToString();
                string buffer6b = buffer6.ToString();
                regNum.Add(buffer1b);
                regNum.Add(buffer2b);
                regNum.Add(buffer3b);
                regNum.Add(buffer4b);
                regNum.Add(buffer5b);
                powNum.Add(buffer6b);
            }
            sreader.Close();
        }
powerpicks.txt
the past winning powerball tickets (some of them; too big to post)
Code:
040513234334
080939475304
021225304838
091029395220
030822424939
072831324014
091323425115
050810162405
142022394414
031014244637
103640424342
071638444818
153439425012
050724283936
272931424633
020507103023
071317203535
212938495242
052546484906
212339444719
102127334002
081517324824
111318324204
080913155009
071633344627
113844455141
061337515225
011135465329
051114225117
050911174639
222832333942
021220225017
050731495314
012434474818
043346485217
142632344406
142125455309
070809315031
091231395232
091120315014
071821284901
122634444809
051820405203
030914172508
101822374509
334041515206
071621334225
121415214330
192129324632
071830414506
092526284226
022836424640
011725435138
071217274524
112021223901
131924333908
111618215116
112948525536
031319324618
122730374726
013437445533
182025313607
091220374917
072528464819
060829414942
091235415136
232937404538
012128324109
111925385035
072340465241
101720234531
091327405328
031018464808
082230334906
041015485113
121518275236
212527414825
182128495016
091015182909
113437444723
101116404402
111620294112
053243474833
112332333438
091832334927
212637495125
212327385038
091122244302
040710303737
222326444712
242933384407
293239455316
020711243118
012529304512
010611385311
060716415323
131735455002
060916223004
032836384401
162835364731
031947495304
042945485001
152531364637
050626333413
142129434526
182233384019
113543454842
202730404811
111740445121
152449505240
011117414624
052022364211
051417454641
010310474827
050619445028
021329323504
162833353717
112540414803
061434374007
021427313609
__________________
Quote:
Originally Posted by Radwen
You should crush your pills and sniff them.

Last edited by Storm33229; 07-24-2008 at 12:19 PM.
Storm33229 is offline  
Old 07-24-2008, 12:34 PM   #9 (permalink)
Master of the Internet
 
Anti-Basic's Avatar
 
Join Date: Dec 2005
Age: 20
Posts: 12,927
Default

Use the Power of the Secret.
__________________
Quote:
Originally Posted by madmadmax3 View Post
I didn't insult anyone dumpass
Anti-Basic is offline  
Old 07-24-2008, 01:03 PM   #10 (permalink)
Forum Expert
 
Join Date: Jul 2003
Location: Arizona
Age: 18
Posts: 3,186
Send a message via AIM to Storm33229 Send a message via Yahoo to Storm33229
Default

Quote:
Originally Posted by Anti-Basic View Post
Use the Power of Secretion.
Roger that.
__________________
Quote:
Originally Posted by Radwen
You should crush your pills and sniff them.
Storm33229 is offline  
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5