Click here to Skip to main content
15,793,452 members
Please Sign up or sign in to vote.
3.00/5 (3 votes)
See more:
How to shuffle the lines in a text file?
Updated 3-Nov-10 11:12am
fjdiewornncalwe 3-Nov-10 9:55am    
You need to be a little more specific than this.
Abhinav S 3-Nov-10 9:58am    
Little more information required.
Rajesh Anuhya 3-Nov-10 10:00am    
More Clarification required on your Question

You may read the lines into an array of strings and then shuffle the array indices (and finally write back the array into a file).
Share this answer
Here's some LINQ code that shows how to do this as CPallini suggested:

Random random = new Random();
File.WriteAllLines(fileName, File.ReadAllLines(fileName).OrderBy(s => random.Next()).ToArray());
Share this answer
CPallini 3-Nov-10 10:31am    
Wow, that's wonderfully terse.

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