I have a C# Visual Studio 2010 console application that reads lines from an Excel spreadsheet and then generates C# classes accordingly using a StreamWriter.
The generated lines of code in the classes are unformatted - as in they are not indented.
I know I could open those files manually and format them by typing ctrl E + D.
But I need to know how to format them programmatically in the generator application please.
I have tried the following code:
Type typeDTE = typeDTE = Type.GetTypeFromProgID("VisualStudio.DTE.10.0");
DTE dte = (DTE)Activator.CreateInstance(typeDTE, true);
dte.ExecuteCommand("Edit.FormatDocument", @"D:\Dev\ClinicalAuditGenerator\src\ClinicalAuditGenerator\Files\Entity\Patient.cs");
but there are 2 problems
1) the CreateInstance takes nearly 30 seconds
2) the ExecuteCommand throws the following exception:
Command Edit.FormatDocument is not available.
Thanks