0

I'm currently working with the XSD.exe tool to get classes of XSD files. But when I pass a file to the tool, it changes the path/file.

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());

Thats some example code to show you the problem. The output looks like:

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

Of course there is no such file or directory. Do you guys have any idea how to solve this?

Thank ;)

User81772
  • 66
  • 6
  • I don't think it's obvious the file does not exist. Do you refer to lowercase translation? Have you tried to invoke xsd.exe directly without the c++-stuff? – urzeit Oct 28 '15 at 09:32

1 Answers1

0

I found the problem. The path in the above given example is a bad choice. In fact, the path I'm really using contains spaces. The XSD.exe uses spaces to seperate arguments. So you have to add some extra quotations at the beginning and at the end of the path string.

For example :

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