(C#)命令行长度限制 [英] (C#) command line length limits

查看:132
本文介绍了(C#)命令行长度限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的先生们,

我有一个使用命令行参数的程序.普通的摄取方法是拖放.因此,将一个(DICOM | * .dcm)文件(或更多文件)拖到我的程序中,它会读取它们并进行处理,而不会显示表格.没问题.一位同事今天指出,该程序不适用于十二个左右"文件.我尝试了一下,可以使23个项目工作,但是增加了第24个螺钉.错误消息是一个简单的msgbox,内容为:

"Windows无法访问指定的设备,路径或文件.您可能没有适当的权限来访问该项目."在标题栏中显示应用程序的完整路径.

我的猜测是他使用的是深层嵌套或长名称的文件.我在想发生了什么事,就是shell不知道如何用很多参数来使程序路径正确?参数以某种方式阻碍了文件名?我检查了一下,发现有23个项目可以工作时,命令行长度(带有完整的程序路径)为2,075个字符. 雷蒙德 [

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

http://ProCure.com

推荐答案

使用Windows资源管理器/工具"菜单/映射驱动器网络",您可以通过映射驱动器来缩短每个文件路径字母到文件所在的文件夹,使用Windows资源管理器打开该驱动器号,然后选择并双击所需的文件.

:)
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.


这篇关于(C#)命令行长度限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆