Friday, July 31, 2009

How can you view and display your text file to your C# windows application?

Help! I'm kinda confused on doing this program.





You have a .txt file (from Notepad) that has the following input in the first line:





1234567#John Edwards#Ohio





How can you able to view and display these outputs using the C# application, in such a way that '1234567','John Edwards' and 'Ohio' are different inputs, wherein, they are all displayed separately in a label/text button?





Is there any links I could access that involves this kind of problem? Thanks.

How can you view and display your text file to your C# windows application?
http://msdn2.microsoft.com/en-us/vcsharp





http://www.solver.com/sdkplatform.htm





check it out in these site..
Reply:Basically, all you need to do to accomplish this is parse out the string by using some built-in string functions. I forget the actual names of them in C#, but basically you


- get the line from the text file by looking for the delimiter (tab, space, comma, etc) and assigning everything befor it to a string


- get the length of that string by using something like myString.Length


- once you have the length, use a substring function to find the first occurence of a '#'


- using the string length function, and the indexof function, you can get the first component by getting the substring from position 1 to the position of the '#', minus one.





You can use this method to iterate through the rest of the strong, changing the start and end positions as needed.





For help, check out





www.thescripts.com


www.csharpcorner.com





Good luck.


No comments:

Post a Comment