Can I backup my programming some easy way?

dick zelvelder 21 Reputation points
2021-02-06T08:38:28.607+00:00

Two years ago I lost all my programming that I worked on for two years. Apparently, when you start a new project in VS, the old project is lost. I tried to get it back, but never found it. So I quitted using VS and programming. Yesterday, I decided to pick it up again and after a evening of hard work, I renamed my main form and for that reason (probably?) all my code is gone again. I can still start my code and it reproduces my form, but i can not enter design mode any more.

Well, it is probaby my own fault, but is there a simple way (or should i use something else than VS?) to make backups once in a while? In a form that i can also put back easily?

All help much appreciated!

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,764 questions
{count} votes

Accepted answer
  1. Karen Payne MVP 35,466 Reputation points
    2021-02-06T11:53:31.333+00:00

    Hello,

    Use GitHub

    First off it's not feasible to provide everything you need to know on the follow but feel I've covered the basics to keep backups via source control for free of your code.

    Best option is to use GitHub repositories which can be made private or public visibility (there is also internal but recommend private or public). VS2015/VS2017 integrate Git slightly different than VS2019 but no matter a Visual Studio solution can easily be pushed to a selected repository.

    To get an idea how Git works, see Microsoft Learn Git experience in Visual Studio, third party information: Using Git with Visual Studio 2019: The Ultimate Guide.

    Benefits for Git

    • Creating a GitHub account and using Git is totally free.
    • Local changes can be compared to remote changes in Visual Studio or Git Desktop (also free)
    • Sign in to GitHub on any machine to get at your code
    • Create a new branch which allows for things like experimenting or versioning. If you create a new branch and then want to move that code to the main branch there is an option known as merging or merging and squash. Incorporates changes from the named commits (since the time their histories diverged from the current branch) into the current branch. This command is used by git pull to incorporate changes from another repository and can be used by hand to merge changes from one branch into another.
    • In Solution explorer, you can visually see new items not in the repository, changed items (and perform compares) along with deleted items.
    • Unlike other version control (like TFS or SVN) Git keeps all code and local changes on each computer which has cloned from GitHub.
    • If by chance you want to use VS-Code, Git is the default version control and you can flip flop between VS-Code and Visual Studio with no affect to Git operations.
    • If you like, GitHub has command line versions of commands.

    Other solutions

    This is cheap and nowhere as good as Git, install dPack (free Visual Studio extension) and use solution backup which creates a zip file of your current solution. I use DPack for another reason, for the ability to open a folder in windows explorer.

    64714-222222.png

    Tips

    1 Create a folder such as C:\Code (mine is C:\DotNet which sub folders for different versions of Visual Studio e.g. VS2017, VS2019 which project folders beneath) then place your projects there. To ensure projects are created under this folder, under Visual Studio menu

    Tools -> options -> Project and Solutions -> Locations -> set project locations to the main folder e.g. C:\Code

    Now you always know where code is on your computer.

    2 Working off tip 1, let's say you move from VS2017 to VS2019 and unsure if this is good for your code, create a new branch in your repository so if something gets messed up and you want to revert back you can do a pull request or what I do is copy the project from C:\Code\VS2017\SomeProject to C:\Code\VS2019\SomeProject and the git information follows along so you don't perform a commit to the main branch until fully satisfied code works fine under VS2019 then even so you can still create a new branch.

    Here is one of my public repositories (all my work repositories are under private repositories in the enterprise version of Git) that I have to move from .NET Framework 4x to .NET Framework 5. In this case there are two branches (as explained above)

    64670-11111111111.png

    64779-11111111111-1.png

    Your current issue

    >I decided to pick it up again and after a evening of hard work, I renamed my main form and for that reason (probably?) all my code is gone again. I can still start my code and it reproduces my form, but i can not enter design mode any more.

    • Not sure how you renamed the form but the right way is to right click on the form in Solution Explorer and select rename (I mention this because I've seen developers do this wrong).
    • Going with the recommendation of using C:\Code... if a form goes away, traverse to the project folder using Windows Explorer, if the form files are there means you can add it back in, if not there is would be in the recycle bin which means you can recover it if you have not emptied the recycle folder.
    4 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.