How to check if a file exists in a folder?

前端 未结 9 1188
暗喜
暗喜 2020-11-28 23:58

I need to check if an xml file exists in the folder.

DirectoryInfo di = new DirectoryInfo(ProcessingDirectory);
FileInfo[] TXTFiles = di.GetFiles(\"*.xml\");         


        
9条回答
  •  臣服心动
    2020-11-29 00:42

    This is a way to see if any XML-files exists in that folder, yes.

    To check for specific files use File.Exists(path), which will return a boolean indicating wheter the file at path exists.

提交回复
热议问题