zoukankan      html  css  js  c++  java
  • [Tip]Always Quote the commandline arguments that can possibly contain whitespaces

    I recently met a issue that: when starting our app by command line way (passing several arguments to the app), on Win7, the specified file can always be opened after lanuching our app, while on XP, the file is always NOT able to be opened! The final reason is that: for arguments that contain whilespaces, when starting a process with it passed in, on XP, it will split it by whilespaces so no valid file can be found so that file won't be opened; while on Win7, it can always be treated as one argument. Whatever, to mark a argument explicitly, always quote it. See below sample code.

     

            void Main(string[] args)

            {
                String file = "C:\\Program Files\\Autodesk\\AutoCAD 2010\\acad.exe";
                String name = "C:\\documents and Settings\\taox\\Local Settings\\Temp\\_solid_temp.dwg";           
                file = "\"" + file + "\"";
                Console.WriteLine(name);           
                String strInfo = name + " /fi /NoLogo /extapp:ConsoleApplication1";
                ProcessStartInfo startinfo = new ProcessStartInfo(file, strInfo);
                Process pp = Process.Start(startinfo);
                pp.WaitForExit();
            }
  • 相关阅读:
    使用自己的key对app进行签名
    pl/sql中文乱码解决办法
    Oracle存储过程中创建表的权限
    pl/sql中获得sql语句执行后影响的行数
    申请Android Map APIKey
    vs快捷键
    ODAC安装配置与使用详解
    .net不安装Oracle11g客户端直接使用ODAC
    android通过USB使用真机调试程序
    pl/sql中实现字符串分割
  • 原文地址:https://www.cnblogs.com/taoxu0903/p/1848567.html
Copyright © 2011-2022 走看看