我目前正在使用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当然没有这样的文件或目录。你们知道怎么解决这个问题吗?
谢谢;)
发布于 2015-10-28 18:56:30
我找到问题了。上面给出的示例中的路径是一个糟糕的选择。实际上,我真正使用的路径包含空格。XSD.exe使用空格来分隔参数。因此,您必须在路径字符串的开头和结尾添加一些额外的引号。
例如:
string cmdPath= String.Format(@"""{0}""", path);https://stackoverflow.com/questions/33386861
复制相似问题