Question

I am making a console application where I drop files onto the .exe from Explorer and it will move them to the appropriate folder based on rules I have set in the logic of the program.

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

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

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

What am I doing wrong?

Was it helpful?

Solution

Depending on your platform, you may be running into the maximum command line length. See Here for more info.

"On computers running Microsoft Windows XP or later, the maximum length of the string that you can use at the command prompt is 8191 characters. On computers running Microsoft Windows 2000 or Windows NT 4.0, the maximum length of the string that you can use at the command prompt is 2047 characters."

OTHER TIPS

Is the number of files causing the maximum length of the command line (and thus arguments) to be exceeded, which causes this error?

To answer the follow-up, a little more info about the purpose of the app might be required, but if possible you might change your command line args to accept a folder path and a pattern to match all the necessary files you want to route. Or change it to a GUI app with a grid that you can drag-drop into.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top