Click here to Skip to main content
15,907,329 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
any one can help me how to delete a word like "World" from a text file, the text file
contains a lot of more text also but only the text entered in a text is searched and then deleted by pressing a delete button created in a web form.......
Posted

1) Load the text file into memory.
2) Load text from the text file into a variable.
3) Search for the varible for the world 'World'.
4) Replace all words with null strings.
5) Write this string back into the file.
 
Share this answer
 
Comments
RaviRanjanKr 21-Jan-11 0:21am    
Nice Answer Abhinav. +5 for that
Abhinav S 21-Jan-11 0:27am    
Thanks Ravi
Zia Ullah Khan 21-Jan-11 0:57am    
the given guidlines are correct and absolute but i am getting stuck can you give me an example ......if you give an example i will get the idea
Abhinav S 21-Jan-11 1:01am    
Hope this helps - http://www.dreamincode.net/code/snippet3282.htm
Zia Ullah Khan 21-Jan-11 1:15am    
thanks alot i got the idea
you can use this code Syntax
// FileName is your FileName and OldWord is Word which you want to delete
File.WriteAllText("FileName",File.ReadAllText("FileName").Replace("OldWord", "")); 
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900