Why won't my console application work with 25 arguments or more?

I create a console application in which I delete the files in the .exe from Explorer, and it will move them to the appropriate folder based on the rules that I set in the program logic.

The program works fine, but when I select more than 25 files and drop them onto my .exe, I get an error message:

Windows cannot access the specified device, path, or file. You may not have the appropriate permissions for the item.

If I delete only 24 files from the same set, it works fine.

What am I doing wrong?

+4
source share
3 answers

Depending on your platform, you can use the maximum command line length. See here for more details.

"On computers running Microsoft Windows XP or later, the maximum line length you can use on the command line is 8191 characters. On computers running Microsoft Windows 2000 or Windows NT 4.0, the maximum line length you can use on the command line 2047 characters. "

+11
source

Is the number of files causing the maximum command line length (and therefore arguments) that causes this error?

+2
source

To answer the question, you may need a little more information about the purpose of the application, but if possible, you can change the command line arguments to accept the folder path and template to match all the files you need on the route. Or change it to a graphical application with a grid into which you can drag.

+1
source

All Articles