The better option is to create a virtual drive, ready to present information but only after its root directory is opened and the password is entered. On Windows, this is doable using for example our CBFS Connect product, on Linux and macOS this is done using FUSE and "Fuse for macOS" respectively. That is if you can expose the filesystem data using code.
If you want to mount a network drive (via SMB / Windows networking) in place of the virtual drive that you have created, this is trickier - you can mount the network disk proactively but use the filesystem filter driver to block access to the network disk until access is made (e.g. by Explorer) and the password is entered. This is doable using our other product, CBFS Filter.
Particular implementations of both approaches are rather sophisticated to be illustrated using the simple code snippet.