Click here to Skip to main content
12,074,549 members (60,484 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB VB.NET IO
hi to all,

I am working with text files in desktop app(vb.net). Framework is 3.0.
I have a several(e.g. 10) text files each containing 10,000 records.
e.g.
17725534 874893829834
17725535 313554132154
17725536 981521451554
and so on.

I have another file containing 200 records called Missing.txt, from within 10 files.
e.g.
17725534 874893829834 1 st row from 1st file.
27725537 564355432154 3 rd row from 2st file.
57725564 156548545484 30 th row from 5st file.
so on till 200 records.

Now I want to check 10 files for 200 records.
Means, I will take 1 st record from Missing.txt & loop in 10 text files to find the same.

If I found any records in 10 files, either it'll deleted or replaced with zeros(0)(In same file, not in Missing.txt).
I am not able to delete the record or replace the same.
Is there ant IO function to replace particular line or to delete it..?

Thanx..
Posted 19-May-12 2:06am
Edited 30-May-12 3:05am
v4
Comments
OriginalGriff 19-May-12 7:11am
   
I'm a little confused as to what you are doing.
Where does notepad come into this? Are these just text files?
What constitutes a check? Is it specific text? Is the data formatted in some way, or delimited?
Perhaps a relevant code fragment would help?
Stephen Hewison 2 19-May-12 7:16am
   
I'd suggest you're doing something wrong with your Filestream approach. Using code you should be able to process all files in at most a few seconds. Try posting your code so we can see exactly what it is your doing?

Despite that, and I'm not suggesting it's the best approach. You can send key presses to any process using the SendKeys command. This would allow you to use the find and replace features of notepad.
Jαved 31-May-12 5:02am
   
are the records seperated by comma or space? or there is only one record on one line?
Harshad.HBK 2-Jun-12 5:29am
   
only one record in line...
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Your description is pretty confusing. We have no idea what you're really having a problem with, so, the generic explanation:

You have to read the file line by line to find what you're looking for. If you don't find it, write the line out to a new file.

If you do find what you're looking for, manipulate the line however appropriate, then write it to the new file.

Repeat until the end of the source file, then close the files and do whatever you wish with them.


...BTW: They're called "Text Files" not "Notepad Files".
  Permalink  
v2
Comments
VJ Reddy 21-May-12 2:05am
   
Good points. 5!
Harshad.HBK 30-May-12 7:46am
   
I have tried my best to explain my problem now...
And I apologize for my bad English... :(
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Hi Harshad,
Refer this link to achieve your goal-
searching-for-line-of-one-text-file-in-another-text-file[^]

Or follow these steps-
1. read both files line by line [Link][^]
2. split each line on their white spaces [Link][^]
3. for both files, create a 2 dimensional array [Link][^]
4. compare the appropriate columns from your 2 dimensional arrays to each other and check if one contains the other [Link][^]
5. write something back to a 3rd file [Link][^]
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web03 | 2.8.160208.1 | Last Updated 31 May 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100