Salut,
oui tu peux, j'imagines que ton fichier ressemble à ça :
ane
anes
anesse
anesses
baleine
....
L'idée est donc de récupérer ses mots dans un tableau :
string[] res=null;
using(FileStream fs = new FileStream(nomFichier, FileMode.Open, FileAccess.Read))
{
using(StreamReader reader = new StreamReader(fs))
{
res = reader.ReadToEnd().Split(new string[] { "\r\n" },
StringSplitOptions.RemoveEmptyEntries);
sr.Close();
}
fs.Close();
}
Ensuite maintenant que tu as ton tableau de string, tu génères un index aléatoire pour ton tableau :
Random rnd = new Random();
int index = rnd.Next(0, res.Length);
string motAleatoire = res[index];
En espérant t'avoir aidé...