title: How to Save a Generated XSD File
body: <p>I have some code (in c#) that creates a bunch of XML sheets on the fly. At the end of my code I am generating XSDs based on those XML sheets. I am making the XSDs successfully, but saving them as files is what I cannot figure out. My code so far is basically taken from the MSDN page on generating XSDs from XML sheets:</p>
  
  <pre><code>        Directory.CreateDirectory(directoryName);
          string[] directoryFiles = Directory.GetFiles(xmlFilePath);
  
          foreach (string xFile in directoryFiles)
          {
              XmlReader reader = XmlReader.Create(xFile);
              XmlSchemaSet schemaSet = new XmlSchemaSet();
              XmlSchemaInference schema = new XmlSchemaInference();
  
              schema.TypeInference = XmlSchemaInference.InferenceOption.Relaxed;
  
              schemaSet = schema.InferSchema(reader);
  
              //insert code here to save the file
              //stored in schemaSet.Schemas()
          }
  </code></pre>
  
  <p>Any help is appreciated. Thanks.</p>