【问题标题】:XSD.exe changes parametersXSD.exe 更改参数
【发布时间】:2015-10-28 09:07:53
【问题描述】:

我目前正在使用 XSD.exe 工具来获取 XSD 文件的类。 但是当我将文件传递给工具时,它会更改路径/文件。

string fileName = "C:\\TEST\\testFILE.xsd";  
Process p = new Process(); 
p.StartInfo = new ProcessStartInfo("C:\\xsd.exe", "/c /language:CS " +   fileName);       
p.StartInfo.RedirectStandardOutput = true;  
p.StartInfo.RedirectStandardError = true;   
p.StartInfo.UseShellExecute = false;  
p.Start();

StringBuilder error = new StringBuilder();
while (!p.HasExited)                                    
    error.Append(p.StandardError.ReadToEnd());
MessageBox.Show(error.ToString());

这是向您展示问题的一些示例代码。 输出如下:

Error: Could not find file "c:\test\testfile.xsd

当然没有这样的文件或目录。 大家有什么办法解决这个问题吗?

谢谢 ;)

【问题讨论】:

  • 我认为文件不存在并不明显。你指的是小写翻译吗?您是否尝试过在不使用 c++ 的情况下直接调用 xsd.exe?

标签: xsd xsd.exe


【解决方案1】:

我发现了问题。上面给出的示例中的路径是一个糟糕的选择。事实上,我真正使用的路径包含空格。 XSD.exe 使用空格分隔参数。所以你必须在路径字符串的开头和结尾添加一些额外的引号。

例如:

string cmdPath= String.Format(@"""{0}""", path);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-17
    • 1970-01-01
    • 2012-04-30
    • 1970-01-01
    • 1970-01-01
    • 2011-08-14
    相关资源
    最近更新 更多