dumpwallet X
Replace X with your desired directory. For example if you want the private keys to be saved in a text file in drive C with the name of "walletdump', replace X with C:/walletdump.txt
This command will lead you to this error below if you use dumpwallet with that path
Cannot open wallet dump file "(code -8)"
If you change the path to D: or E: drive it will work but on C: drive you will receive that error unless you run the Bitcoin core as an administrator.