FileStream & Read Methods.....Need your opinion!

jmcgurk05

New member
Joined
Oct 10, 2003
Messages
1
Location
Toledo, OH
I have a text file I am reading in with a c# windows application, and I have most of the "reading" figured out. I want your opinions on how to read the rest of it. Here is the text file...(further explanation below)

*******************************
prefName="preform name goes here"
PN=3
PR= 1,4,7
2,5,8
3,6,9
FHT=21
FWT=5
*******************************
Where prefName is the name of the object described in the text file, PN is the number of points (coordinates) that define it, and PR is the coordinate list. 1,4,7 being x values ..... 2,5,8 being y values..... and 3,6,9 being z values. Below is the code I use to find the number of points (PN). The FHT and FWT values are found the same way. Now, in your opinon, what would be the best way to grab the x,y and z coordinates in their own arrays. i.e. x[0] = 1 , x[1] = 4 , x[2] = 7. It must grab a defined number of points for each x,y,z as defined by my global variable prefNumPoints (see code). Also, what would be the best method to grab the name without the quotes and save it as a string within the program? Thank you for your input in advance.

Code:
while ((text = sr.ReadLine()) != null) 
{
Match pn = Regex.Match(text, @"PN=(.*)"); 
					

if(pn.Success && pn.Groups.Count > 1)
{ 
						
SBO2_3.prefNumPoints = Int32.Parse( pn.Groups[1].ToString() );
						
}
 
Back
Top