Matt Wennerlund

I've built a small app (C# .Net 2.x) that will take the files I drop onto it from Windows Explorer, concatenate them, and save the combined file in a specific location. It works fine for up to 38ish files, but when I go beyond that number I receive an error: "Windows cannot access the specified device, path or file. You may not have the appropriate permissions to access the item"

I can access all of the files individually and corporately in small groups, so it is not a permissions issue. I receive the dropped files through Main(args[]), so they come in like a command line. I believe it is that the number of files I have in the args is exceeding the maximum command line length. (8K on WinXP I believe.) I also believe the error is Windows complaining about the last file/path name being truncated to fit the command line length, and so it cannot open the file because the path is incomplete.

I have not been successful in finding a way to access the Windows Explorer file list in another way than passed in via the command line. Any ideas

Thanks for your help.

Matt


Re: Visual C# General Alternative to command line args?

decyclone

May be you could create a windows form and use drag-drop as an alternate to command line arguments. And windows forms supports much more ways to do this.





Re: Visual C# General Alternative to command line args?

dape

Hi,

It is probably a shell and/or create process issue. W32 CreateProcess allows the commandline to contain 32K chars, except W2K that only can hold MAX_PATH chars.

On my Vista machine the magic border is somewhere around 50 files ~ 2000 chars.

best regards,

Daniel Petersson

My small hack to test the issue:

namespace ListEm

{

class Program

{

static void Main( string[] args )

{

int sum = 0;

for ( int i = 0; i < args.Length; i++ )

{

string arg = argsIdea;

Console.WriteLine( "{0} : {1}", i, arg );

sum += arg.Length;

}

Console.WriteLine();

Console.WriteLine( Environment.CommandLine );

Console.WriteLine( "Raw count: {0}", Environment.CommandLine.Length );

Console.WriteLine( "{0} args listed {1} chars", args.Length, sum );

Console.ReadLine();

}

}

}





Re: Visual C# General Alternative to command line args?

Wiggly

I would suggest if you have a large amount of information that needs to be feed into the system the args is not the place to do it.

1) As perviously suggested if it doesn't need to be a console app then forms would be a neat solution as you can find all your files easily that way.

2) if the files are all of a certain type.. or all in certain directories you can search for them from within the program:

directoryinfo and fileinfo classes

3) if you want it to be a console app and the files are not easy to search for I would use a text file or xml file to hold the reference to all of the files. How ever you populate the args line could (I imagine) be changed to populate the file instead. This way there is no limit to how many files you have.

Twiggy






Re: Visual C# General Alternative to command line args?

Matt Wennerlund

decyclone wrote:
May be you could create a windows form and use drag-drop as an alternate to command line arguments. And windows forms supports much more ways to do this.


I was hoping just to do drag and drop from Windows Explorer. I am duplicating the functionality of a Mac app on Windows. Our warehouse workers are just used to dragging and dropping certain files from a folder onto the app itself rather than starting it up and dropping to a window. I can retrain them if i can't get this to work.

Thanks,
Matt





Re: Visual C# General Alternative to command line args?

Matt Wennerlund

Wiggly wrote:

I would suggest if you have a large amount of information that needs to be feed into the system the args is not the place to do it.

1) As previously suggested if it doesn't need to be a console app then forms would be a neat solution as you can find all your files easily that way.

2) if the files are all of a certain type.. or all in certain directories you can search for them from within the program:

directoryinfo and fileinfo classes

3) if you want it to be a console app and the files are not easy to search for I would use a text file or xml file to hold the reference to all of the files. How ever you populate the args line could (I imagine) be changed to populate the file instead. This way there is no limit to how many files you have.

Twiggy




My users pick the files they need from a directory and drag and drop to the app. A search would not really work in this case, but it is something to consider.

Thanks,
Matt




Re: Visual C# General Alternative to command line args?

OmegaMan

Matt Wennerlund wrote:
I've built a small app (C# .Net 2.x) that will take the files I drop onto it from Windows Explorer, concatenate them, and save the combined file in a specific location. It works fine for up to 38ish files, but when I go beyond that number I receive an error: "Windows cannot access the specified device, path or file. You may not have the appropriate permissions to access the item"

I can access all of the files individually and corporately in small groups, so it is not a permissions issue. I receive the dropped files through Main(args[]), so they come in like a command line. I believe it is that the number of files I have in the args is exceeding the maximum command line length. (8K on WinXP I believe.) I also believe the error is Windows complaining about the last file/path name being truncated to fit the command line length, and so it cannot open the file because the path is incomplete.

I have not been successful in finding a way to access the Windows Explorer file list in another way than passed in via the command line. Any ideas

Thanks for your help.

Matt



Check the System.Environment.CommandLine, it will provide you with an alternate route of accessing the information. That may help you with the file number issue.




Re: Visual C# General Alternative to command line args?

Matt Wennerlund

OmegaMan wrote:
Matt Wennerlund wrote:
I've built a small app (C# .Net 2.x) that will take the files I drop onto it from Windows Explorer, concatenate them, and save the combined file in a specific location. It works fine for up to 38ish files, but when I go beyond that number I receive an error: "Windows cannot access the specified device, path or file. You may not have the appropriate permissions to access the item"





Check the System.Environment.CommandLine, it will provide you with an alternate route of accessing the information. That may help you with the file number issue.



It does get me an alternative access to the command line args, but the same 8kb-ish limit is still in place. I can drag and drop as many files as I want to between Explorer windows, I am hoping to access that internal Explorer file list.

Thanks for your answer.

Matt





Re: Visual C# General Alternative to command line args?

OmegaMan

Hi Matt,

I was able to reproduce the issue quite easily. I searched Microsoft Connect to see if this had been reported as a bug or not. I could not find any bug listed. I went ahead and created a bug report entitled:

Command Line Arguments Cannot Handle More than 8K of data

Log on and vote for the issue if you feel it merits MS looking at it.

For now I suggest you retrain your people, for even if they fix it, it at the earliest would not come out til Orcas is released which won't be for a few months.