Nice work. Some feedback:
Using the file system is going to degrade in performance very quickly. It's a nice idea for a URL shortening system that only you use (< 100 URLs), but file I/O is going to be MUCH slower than simply using a database. You also miss out on data compression that you get for free with all database storage engines.
Most importantly, it also limits you quite a lot if you ever wanted to enhance your program. Let me give you an example.
Right now you are not caching URLs that already exist. This should be fixed because there is no point storing the same URL with different codes. To fix this, you will need to look for the given URL in each file. This is a linear operation, but the sheer amount of IO required to open every file, read it's contents, check for equality and then close the file is going to be a total killer for your app if you have millions of URLs!
We’re a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.