Notifications
Clear all
[Closed] Common way of dealing with filepaths
Aug 13, 2014 2:49 pm
Ok so I have a filepath “C:\bla\yada\yodo\yaddee”
and I want to reuse it in a function and it wants a “C:\bla\yada\yodo\yaddee” what is the common way to deal with this? Regex is too allien and complicated to me… :surprised
any suggestions?
3 Replies
Aug 13, 2014 2:49 pm
@"C:\bla\yada\yodo\yaddee"
@"C: adaa\" == "C:\ adaa\\"
"C: adaa\" != "C:\ adaa\\"
-- because gets expanded to tab character and \" gets expanded to " character.
-- Also, in both rightmost strings // gets expanded to /.
-- If you add @ before the string, the string is not expanded and is passed as it is written.
Aug 13, 2014 2:49 pm
change to forward slash if it in a variable.
substitutestring path "\\" "/"
use path with leading @ if it’s a text
doesfileexist @"c:\blah\bloh.blih"