FileStream fsXslt = null; FileStream fsInput = null; FileStream fsExtensions = null; FileStream outStream = null; try { // Преобразование fsXslt = new FileStream(xsltPath, FileMode.Open, FileAccess.Read); fsInput = new FileStream(instancePath, FileMode.Open, FileAccess.Read); fsExtensions = (extensionPath != null) && (extensionPath.Length > 0) ? new FileStream(extensionPath, FileMode.Open, FileAccess.Read) : null; BizTalkMap map = new BizTalkMap(fsXslt, fsExtensions); Stream sOut = map.TransformInstance(fsInput); // Сохраняем результат в файл string destPath = Path.Combine(Path.GetDirectoryName(instancePath), Path.GetFileName(instancePath) + «.trans.xml»); outStream = new FileStream(destPath, FileMode.Create, FileAccess.Write); outStream.Write(((MemoryStream) sOut).ToArray(), 0, (int) sOut.Length); } finally { if (fsXslt != null) fsXslt.Close(); if (fsInput != null) fsInput.Close(); if (fsExtensions != null) fsExtensions.Close(); if (outStream != null) outStream.Close(); }