I want C# to read one random line from a .txt file (low two digit numbers of entries on the largest files with less than 35 characters).
I used File.AppendAllText to write to .txt files before. I tried a few solutions, but they don’t seem to work for me here. Unfortunately, I’m not the best at coding.
using System;
using System.IO;
public class CPHInline
{
public bool Execute()
{
//This will get the folder path for the file that is supposed to be read in format "X:FolderFolder2".
string pathF = CPH.GetGlobalVar<string>("File path", true);
//This contains the file name which changes sometimes. This variable combines the folder path and file path to the final path.
string path = $"{pathF}Medium.txt";
//The string "message" is supposed to contain the random read line.
string message = //The read random line from the .txt file is supposed to be a the value of the variable.
//From here on out, this is the part where the random line get's processed further.
string voice = CPH.GetGlobalVar<string>("TTS speaker", true);
CPH.SendMessage(message, false);
CPH.TtsSpeak(voice, message, false);
return true;
}
}