what is the sleakest way to proccess multiple file

2019-06-11 11:31发布

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.

4条回答
迷人小祖宗
2楼-- · 2019-06-11 12:02

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.

查看更多
劫难
3楼-- · 2019-06-11 12:06

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.

查看更多
一纸荒年 Trace。
4楼-- · 2019-06-11 12:10

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.

查看更多
Emotional °昔
5楼-- · 2019-06-11 12:21

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

查看更多
登录 后发表回答