简体   繁体   English

.NET控制台应用程序命令行解析文件参数

[英].NET Console app command line parsing of file arguments

I am doing a command line app that needs to read some files and do some processing. 我正在做一个需要读取一些文件并进行一些处理的命令行应用程序。

There can be many file arguments on the command line, and each of these can be in one of the following formats: 命令行上可以有许多文件参数,每个参数都可以采用以下格式之一:

  • Relative path, with or without wildcards. 相对路径,有或没有通配符。
  • Complete path, with or without wildcards. 完整路径,带或不带通配符。

Network shares should be supported. 应支持网络共享。

What is the easiest way to get a collection of all the files matching the command line arguments ? 获取与命令行参数匹配的所有文件的集合的最简单方法是什么?

Examples of command lines that should be supported: 应支持的命令行示例:

tool.exe myfile.dat
tool.exe myfile.*
tool.exe ..\..\*.*
tool.exe C:\Temp\test.*
tool.exe \\server\share\*.dat

Is there nothing built-in in the framework to do this ? 框架中没有内置任何内容来执行此操作吗?

This question has a couple of good code samples and some discussion. 这个问题有几个很好的代码示例和一些讨论。 Here is another article that explains it and the code is a little simpler. 这是另一篇解释它的文章 ,代码更简单一些。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何通过 docker 运行将命令行 Arguments 传递到 .NET 控制台应用程序(Docker for Windows) - How to pass Command Line Arguments to .NET Console App through docker run (Docker for Windows) 将命令行 Arguments 传递到 C# .NET 应用程序而不使用 ZADD4E130E8FD245A30CDED0AB1 内的清单文件 - Passing in Command Line Arguments to C# .NET app Without Using Manifest File Inside a UWP App 解析不同格式的命令行参数 - Parsing command line arguments of different formats 命令行参数、带空格的路径、解析不正确 - Command line arguments, paths with spaces, parsing incorrectly 如何在C#控制台应用程序中使用命令行参数? - How do I use command line arguments in my C# console app? 如何在 VS2022 中使用新的控制台应用程序模板访问命令行参数 - How to access command line arguments with new Console App template in VS2022 在控制台应用程序中,防止转义命令行参数中特殊序列的最佳方法是什么? - in a console app what's the best way to prevent special sequences in command line arguments from being escaped? ASP.NET命令行参数 - ASP.NET Command Line Arguments 用于转义.NET命令行参数的规范解决方案 - Canonical solution for escaping .NET command line arguments 如何在没有命令行参数的情况下重新启动应用程序 - How to restart app without Command Line Arguments
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM