。
I was at a loss as to what to do.
Literal
How do-[and-て] good [question-か] way-lost became.
Subject omitted (clearly the speaker). 途方に暮れる is a fixed idiom — literally 'to be enveloped in the direction of a way,' meaning 'to be at a complete loss.' The embedded どうしてよいか is an indirect question ('what to do') using the archaic-feeling よい (literary form of いい), lending a slightly formal tone.