public static bool Scramble(string fullPath) { if (File.Exists(fullPath)) { List <string> all = File.ReadAllLines(fullPath).ToList(); List <string> otp = new List <string>(); List <int> indexes = new List <int>(); for (int i = 0; i < all.Count; i++) { indexes.Add(i); } while (indexes.Count > 0) { int i = Informers.CreateRandInt(0, indexes.Count); int ind = indexes[i]; otp.Add(all[ind]); indexes.Remove(i); } File.WriteAllLines(fullPath, otp); return(true); } else { return(false); } }
public static string GetRandomLineFromFile(string fileName) { string[] lines = File.ReadAllLines(fileName); int lineNo = Informers.CreateRandInt(0, lines.Length); string line = lines[lineNo]; return(line.Replace("\"", "").Replace(",", "").Replace(";", "").Replace("\'", "")); }