visual-studiomsbuildmacroskeyboard-shortcutscoderush

Delete a specific file with a shortcut key


Is there a way to delete a specific file or 2 files with a shortcut key in Visual Studio? The path is will be a dynamic path of the current selected/active project.

That is no matter for me to use a 3rd party tool, macros, extensions, batch files, CodeRush or whatever (using some other Windows apps or ...).


Solution

  • You can create a command and assign a shortcut to it with my Visual Commander extension.

    In the command, to get the project path for the active document window:

    string projectFile=DTE.ActiveDocument.ProjectItem.ContainingProject.FileName;
    

    To delete a file:

    System.IO.File.Delete(path);