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
mwmosu
NA
10
0
loop through a .doc file and delete specified lines
Jun 3 2004 5:58 PM
I am trying to loop through a .doc file and delete specified lines. Here is the code I have so far: try { // Create an instance of StreamReader to read from a file. // The using statement also closes the StreamReader. using (StreamReader sr = new StreamReader(tmpdir + newfilename)) { File.OpenWrite(tmpdir + newfilename); FileInfo f = new FileInfo(tmpdir + newfilename); string line; int c = 0; string sentinel="start"; // Read lines from the file until the end of the file is reached. if (f.Length > 0) { while (f.Length >= c) { if (line.IndexOf("GOTO 9988") == 0) { sentinel = "stop"; } else if (line.IndexOf("<9988>") == 0) { sentinel = "start"; } if (sentinel == "start") { //HERE IS WHERE THE CODE GOES TO REMOVE //ANY LINE THAT IS READ WHEN SENTINEL = START } c++; } } catch .......... } } Any help is appreciated.
Reply
Answers (
0
)
I've been reading all day and I can't find it....
Change OLE Link Path in Word Documents