Tai Kahar
Tai Kahar

Reputation: 304

How to force System.IO.Path.GetDirectoryName(string path) to use / in Windows Environment

I want to have slash instead of backslash, because my application communicates with a ftp not allowing backslash as directory-seperator.

Is there any shortcut/configuration without writing my own method?

Upvotes: 7

Views: 3531

Answers (1)

Paul Turner
Paul Turner

Reputation: 39625

Stealing @Tejs comment as an answer.

Since GetDirectoryName returns a string, you can simply replace the backslashes with the symbol you prefer:

Path.GetDirectoryName(path).Replace("\\", "/")

Upvotes: 3

Related Questions