Description
Normally, deleting the IDE should not erase your sketches. They're stored in a separate location called the "sketchbook".
However, perhaps you had the sketchbook location incorrectly configured to be the same directory as your Arduino installation? This is already filed as issue #2719
Could you look in File > Preferences and tell us what directory is configured for your sketchbook? And of course, what directory is actually being used for Arduino? I realize on Windows and modern Macs, many of the graphical programs for managing files try to "simplify" file systems by obscuring locations, so it may not be easy for you to get accurate info about where things really are on your computer's filesystem. If File > Preferences, you can turn on verbose output while compiling, which will print compiler commands when you Verify or Upload. Some of those will have the real, full pathnames.
If we're ever going to prevent this problem from wiping out anyone else's files in the future, we've really got to collect accurate info about exactly where you had things installed. My hunch is this may be the already-known case of issue #2719, but really that's just a blind guess.
I've seen a couple other comments on the Arduino forum about something similar happening. Maybe that was also you? Or maybe this is a problem that's hitting multiple people? I really want to figure out what happened and eventually add code to Arduino to make sure nobody else suffers this fate. But until we understand why, the best I can say is maybe it's #2719, or maybe it's some other misconfiguration nobody has understood yet? I know I've deleted and reinstalled Arduino many hundreds of times while developing features and testing, and I've never managed to stumble across this situation... so I really need details from you.
Originally posted by @PaulStoffregen in #2773 (comment)