Click here to Skip to main content
14,737,711 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Sirs,

I have a program that takes command-line arguments. The ordinary method of ingestion is drag-n-drop. So, you drag a (DICOM|*.dcm) file (or more) onto my program, it reads them and processes them without showing a form. No problem. A coworker pointed out today that the program doesn't work with "twelve or so" files. I tried it and can get 23 items to work, but adding the 24th screws it up. The error message is a simple msgbox saying:

"Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access the item." With the full path to the application in the title-bar.

My guess is that he was using rather deeply-nested or long-named files. I'm thinking what's happenning is that the shell is somehow not getting the program path correct with lots of parameters?? the parameters somehow obstructing the filename?? I checked it out and when I get the twenty-three items to work, the command-line length (with full program path) is 2,075 characters. Raymond[^] has lots to say about it, but my length isn't close to what he talks about: I'm nowhere near 32767, over 2048, and not near 8192, and well over the dos limit of 127.

I could do something creative if my program would just run, but it never gets to sub Main().

If anyone has had this problem before, please give me sympathy. Even better, if someone knows how to work around or fix this problem, please let me know!! I've searched the web for a while and nothing came up. I was sure to check this forum to avoid double-posting. Thanks!

In Christ,
Aaron Laws
Updated 5-Apr-10 22:15pm

Using Windows Explorer/Tools menu/Map Drive Network, you might be able to shorten each of the file paths by mapping a drive letter to the folder your files are in, opening that drive letter using Windows Explorer, then selecting and double-clicking the files you want.

Just something else to look at. I've had similar issues where the space character being embedded in one of the folder names caused problems. Generally the highlighted files end up being tokenized by a space character and so an embedded one causes one filename to be split across two arguments.
If you have the source code to the app you're trying to run, why don't you save your commandline arguments to a data file and either pass that argument file as the parameter, or make your app look for it automatically.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900