如何动态指定DOS文件? [英] How do I dynamically specify a file in DOS?

查看:166
本文介绍了如何动态指定DOS文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用C#.NET中运行DOS命令为FTP方式的文件。从技术上讲,它调用它调用其执行DOS代码CMD文件BAT文件。这是到CMD文件。在CMD FIEL将工作,如果我硬编码路径,但我需要动态指定文件的路径。

I am trying to use c# in .net to run dos commands to ftp a a file. Technically, it calls a BAT file which calls a CMD file which executes the DOS code. It was up to the CMD file. The CMD fiel will work if I hardcode the path, but I need to dynamically specify the path of the file.

BAT文件...

ftp.exe -s:%~dp0\mycmdfile.cmd

在cmd文件...

open <my ost>
<my user name>
<my pw>
quote site cyl pri=1 sec=1 lrecl=1786 blksize=0 recfm=fb retpd=30
put <here is where I need the dynamic path> + localfilename remotefilename



退出

quit

推荐答案

我想补充到扎卡里,你可以参考命令行里的蝙蝠瓦尔%1%2,依此类推。

I would add to Zachary that you can refer to command line vars inside bat with %1, %2, and so on.

%〜DP0 语法只能从Windows 2000(如果我记得是正确的)。指从另一个目录中的文件只是改变到一个目录只是 CD 到该目录,然后从中调用命令。

%~dp0 syntax is only available from Windows 2000 (if I remember it right). To refer to files from another directory just change to a directory just cd to that directory and then invoke command from it.

这篇关于如何动态指定DOS文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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