|
||
|
|||||||
| 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 |
|
|
#1 (permalink) | |
|
Forum Expert
|
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:
|
|
|
|
|
|
#3 (permalink) | |
|
Forum Expert
|
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:
|
|
|
|
|
|
#4 (permalink) |
|
ConnectUO Creator
Join Date: Jan 2004
Age: 28
Posts: 4,891
|
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 |
|
|
|
|
#6 (permalink) |
|
Master of the Internet
Join Date: Apr 2005
Location: Nowhere
Age: 22
Posts: 11,653
|
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 |
|
|
|
|
#8 (permalink) | |
|
Forum Expert
|
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();
}
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:
Last edited by Storm33229; 07-24-2008 at 12:19 PM. |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|