Reputation:
Is there a convenient function to regularize a file path in c#?
I have a command-line program which accepts a file path from the user. If they are being too clever, they might supply something like "c:\\mypath", which c# represents internally as "c:\\\\mypath"
I'd like to process the paths so they are regularized to "c:\\mypath"
I could use a string replace where I replace "\\\\" with "\\", but is there a more elegant platform independent way?
Upvotes: 3
Views: 530
Reputation: 55022
use Path. it will handle it for you and will provide you all the functionality you want.
Upvotes: 6