TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Dinesh Santhalingam
NA
737
368.7k
File parse in c#
Jan 18 2017 5:21 AM
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace readfrom_textfile {
class Program {
static void Main(string[] args) {
var
fileStream
=
new
FileStream(@"D:\Practise\test.txt", FileMode.Open, FileAccess.Read);
using(var
streamReader
=
new
StreamReader(fileStream, Encoding.UTF8)) {
string line;
while ((
line
=
streamReader
.ReadLine()) != null) {
string[]
data
=
line
.Split(new char[] {
'('
}, StringSplitOptions.RemoveEmptyEntries);
string
bikeName
=
data
[0].Trim().Split(' ').Last();
bikeName
bikeName
= bikeName.Remove(bikeName.Length - 1);
string[]
usageData
=
data
[1].Split(new char[] {
';'
}, StringSplitOptions.RemoveEmptyEntries);
string
issuedBike
=
usageData
[0].Trim().Split(' ')[2];
string
inUseBike
=
usageData
[1].Trim().Split(' ')[2];
Console.WriteLine("Name:" + bikeName);
Console.WriteLine("Total:" + issuedBike);
Console.WriteLine("InUse:" + inUseBike);
Console.WriteLine();
}
}
Console.ReadLine();
}
My text file contains:
Users of Yamaha: (Total of 2 bike issued; Total of 2 bike in use). line1....................something
line 2..................something
Bike details //emptyline
1125 Monica YamahaR15(v3.0)(petrol / 7788 4903), start Wed 1 / 18 8: 53 1128
Dhini Yamaha Fz(v2.0)(petrol / 7748 4903), start Wed 1 / 18 9: 53
O/p like this...
Name: Yamaha;
Total: 1;
Inuse: 1;
members: Monica[Wed 1 / 18 8: 53], Dhini[Wed 1 / 18 9: 53]
I did something fine using my code but i can't achieve 100%.Please help me to solve the problem.
Reply
Answers (
8
)
Show Checkbox Control In The Row Of Datagridview
How to print qr code image and related data to report ?