Is it possible to make a program, that can set passwords on folders if it is running in the background?

So etc. if now i open i my schoolprojectfolder, there will come a box, where you must type in a username and password. If the username or password is wrong, det folder wont open?