Click here to Skip to main content
15,911,789 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hallo, I have desktop application when I use my text file where i randomly pick some words. Each word is on single line. But I want to edit possibility, that user can load his own words. But when i load it, I need to modify his file same like me. User has write in file for example: "word;word2;word3 or word word2 word3", he has words on same line separated by semicolon or space and I need to split word by enter to be on sigle line. I had tried something like replace ";" by "\r\n" or something like this.
Posted
Comments
BillWoodruff 15-Mar-15 7:31am    
Since, as Peter suggests in his answer here, you can split the text of the file on all-of carriage returns, semi-colons, and spaces to get an indexable array of words, why bother to change the file ? If you wrote the "rules" for the users, why do you need to do this ?

1 solution

1. Split the input string using String.Split[^]
2. Open you file for append: https://msdn.microsoft.com/en-us/library/system.io.file.appendtext%28v=vs.110%29.aspx[^]
3. Use WriteLine[^] in a loop to add new words...
4. Close the file...
 
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