Open All Code and Designer Windows

 < Free Open Study > 

Make a Backup Copy of the Current Window

Before you make massive changes to a source file, you might want to make a backup copy of the file. If you later decide that you want to restore the copy of the source code before you made the changes, you will have a copy to restore. Obviously, you could do this manually through the Windows Explorer, but you can do it very easily within the IDE with the following procedure:

    Sub BackupCurrentWindow()      " This method will make a backup copy of      " the active window. It will be saved as      " fullname.bak. For example, a .vb file      " will be saved as name.vb.bak. The file      " will be saved and closed. It will not      " be added to the project.      Dim Sel As TextSelection = oVB.ActiveDocument.Selection      Dim sFileName As String = oVB.ActiveDocument.FullName & _          ".bak"      Dim epAnchor As EditPoint = Sel.AnchorPoint.CreateEditPoint      Dim epActive As EditPoint = Sel.ActivePoint.CreateEditPoint      Dim txtWin As TextWindow = oVB.ActiveWindow.Object      Dim actPane As TextPane = txtWin.ActivePane      Dim Corner As EditPoint = actPane.StartPoint.CreateEditPoint      Dim Text As String      Sel.SelectAll()      Text = Sel.Text      ' Create, save, and close the backup copy of the      ' current window      oVB.ItemOperations.NewFile("General\Text File")      oVB.ActiveDocument.Object("TextDocument").         Selection.Insert(Text)      oVB.ActiveDocument.Save(sFileName)      oVB.ActiveDocument.Close(EnvDTE.vsSaveChanges.          vsSaveChangesNo)      ' Restore the selection.      Sel.MoveToPoint(epAnchor)      Sel.MoveToPoint(epActive, True)      actPane.TryToShow(Corner, vsPaneShowHow.vsPaneShowTop)    End Sub

 < Free Open Study > 

Writing Add-Ins for Visual Studio  .NET
Writing Add-Ins for Visual Studio .NET
ISBN: 1590590260
EAN: 2147483647
Year: 2002
Pages: 172
Authors: Les Smith © 2008-2017.
If you may any questions please contact us: