私は C# を使用していますが、ローカル ドキュメント内で (コンソール アプリケーションで) ユーザーにファイル名を尋ねる方法があるかどうか疑問に思っていました。オンラインでこの質問を構成する方法がよくわかりませんが、私が持っているコードは次のとおりです。
static void Main(string[] args)
{
string[] random1 = System.IO.File.ReadAllLines(@"//..Random1.txt");
foreach (string r1 in random1)
{
Console.WriteLine(r1);
}
しかし、理想的には、次のようなものが必要です。
static void Main(string[] args)
{
Console.WriteLine("Enter the name of the file you would like to see")
// Following the input let's say " Potato.txt " is entered
string[] chosenFile1 = System.IO.File.ReadAllLines(@"//..Potato.txt");
foreach (string file in chosenFile1)
{
Console.WriteLine(file);
}
通常はファイルのパスに依存するため、どうすればよいかは完全にはわかりませんが、さまざまなデバイスのさまざまなユーザーがこれを試すことができるため、この方法がより適切だと思いました. これが理にかなっていることを願っています。すべての助けに感謝します。