There is no country tag, so I'll post an answer, although it is obviously outdated.
For many years, in Russia, this was possible, and I had been doing this several times. It was done very similar to buying any investments (stocks etc.) through brokerage account open at my bank (or actually at a broker company owned by my bank).
I would transfer rubles from my regular ruble bank account to this brokerage account, then buy dollars on Moscow exchange with exact exchange market rate, then transfer dollars to my dollar bank account in the same bank, then I could do anything with it: withdraw dollar cash from ATMs of that bank, pay with a dollar bank card, transfer dollars via SWIFT, etc.
Of course, there was some fee for transactions on the exchange, but it was rather low, something like 0.5%, much lower than the typical bank exchange rate spread. All the transfers were free, as they were within the same bank. Probably there was some minimal sum, or the sum had to be a multiple of some fixed amount, but these were definitely not prohibitively high, maybe $1000.
Obviously it is not possible to do this anymore, although I have not checked it recently, probably it is still possible to buy yuans...