Notifications
Clear all

[Closed] Common way of dealing with filepaths

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

Verbatim string literals?:

@"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.

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"

thank you guys, got it working ;]