In Visual FoxPro. there is a function addbs(), to which you pass a string.
If there is not a backslash at the end of the (trimmed) string, it will add one. If there is a backslash, it will return the trimmed string.
lcString = 'C:\Example'
lcNewString = addbs(lcString)
?lcNewString
Output:
C:\Example\
Is there an equivalent function in C#?
lcString = lcString.EndsWith("\") ? lcString : lcString + "\";
? – Corak Apr 12 '13 at 8:28Path.Combine
. – Daniel Hilgarth Apr 12 '13 at 8:31AddBS
,AddFS
,AddDot
... – Corak Apr 12 '13 at 8:38