【问题标题】:c# Searching for a file which the user has typed inc#搜索用户输入的文件
【发布时间】:2017-04-16 05:05:12
【问题描述】:

我希望我的程序读取用户的输入,然后获取该输入并找到他们要求的文件。

我的代码:

fileName = Console.ReadLine();
if(File.Exosts(fileName)){

do something
}

【问题讨论】:

  • 你确定应该是文件Exosts吗?
  • 你想对文件做什么?

标签: c# file search


【解决方案1】:

试试:

  foreach (String s in Directory.GetFiles(targetDirectory)){
   if(fileName.Equals(s)){
    //do something
   }else{
   MessageBox.Show("File not found in "+targetDirectory);
   }
  }

Directory.GetFiles()

Files

【讨论】:

    猜你喜欢
    • 2019-03-21
    • 2021-11-23
    • 1970-01-01
    • 2017-04-14
    • 2013-08-31
    • 2015-11-25
    • 1970-01-01
    • 1970-01-01
    • 2015-02-24
    相关资源
    最近更新 更多