views:

138

answers:

4

I am trying to start a program by dragging multiple files on to the .exe and then have the exe send the files to diffrent folders based on rules and logic in the program itself.

the problem i am running into is that i do this via a console application there is a limitation on how much information can be sent to the exe at a time.

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.

what would be the most minimalistic way around this issue? I would like to avoid having a program running in the background at all times if possible.

A: 

you could write the "data" to a file and have the file as argument?

Petoj
I dont think starting up program 1 to read in data that would make a file that would start program 2 would qualify as a easier way to do things. Also i would just run into the same limitation with program1 not being able to read in all the files.
Crash893
+3  A: 

Instead of dragging files to an ".exe" perhaps you could create a "hot folder" to drop the files into. You'd need to write your application to monitor this folder (using something like FileSystemWatcher) and process the incoming files.

Craig
" I would like to avoid a program running in the background if at all possible" - this is my back up idea i already have a prototype in the works but it just seems like a waste of resources to have this run when it might get used for like 30 seconds a month
Crash893
You don't have leave your application running all the time when monitoring a folder. Start it up when when you're ready to drop the files in the 'monitoring-folder', FileSystemWatcher notifier will raise an event when it detects any new file dropped in the folder.
Mez
+1  A: 

It's not C#, but you could write an Explorer Shell extension to add "Route File(s)" to the default context-menu when you right-click a file or select a group of files (anywhere, not just limited to contexts where you can see your executable), as this API would probably not limit you to the command line arg length limitations.

There. Sleek, and no background process. The only downside is that you have to write it as a COM component.

TheMissingLINQ
a good idea, do you have any examples?
Crash893
Nah I tend to avoid COM like the plague. Here's some quick googling of the problem keywords.http://www.codeproject.com/KB/shell/shellextguide1.aspx
TheMissingLINQ
There is no need to use COM; see my answer below.
lavinio
+2  A: 

There is a way to write a .net program that watches a specific folder using the FileSystemWatchter class. I wrote an example of some code to do this calling our company's product, but you could use the skeleton to do just what you want.

The idea is you point to a folder and subscribe to certain events on that folder (files renamed, added, deleted, etc.) so that when those events happen, your code is triggered. In between, your program just waits.

Then you could just have that folder be a folder on your desktop, and as you drop stuff into it, things "magically" happen.

A Visual Studio 2005 solution is also on the site.

Hope this helps.

lavinio
I appreciate the help but its not what i wanted to so ( i should point out that I did back out to the FSW) but i view the question as answered by the fact that you cant do it the way i wanted. thanks
Crash893