Search code examples
c#visual-studiovsixenvdte

VS Extension VSIX Save all unsaved documents


Is there a way to save all unsaved documents (files with the '*' in the VS editor tab) using DTE or something else in a VSIX command?

unsaved file

I'm creating a command that reads the current document's syntax tree, but I cannot access unsaved changes made to that document, so I wish to save all files open in the editor before running my code.


Solution

  • DTE.ExecuteCommand("File.SaveAll");
    

    This will execute the Save All command, as if you executed it from GUI:

    1