Is there an easy way of dynamically building a filepath in .Net? At the moment I'm building the filepath by concatenating various strings (from application settings, user input and Date.ToString) but this relies on there not being double '\' characters or illegal characters etc in the strings. Obviously I can manually validate the strings for this sort of thing but I was wondering if there was something built into .Net that can handle this.
Use Path.Combine
Dim p = Path.Combine(somePath, "foo\bar")
Documentation: http://msdn.microsoft.com/en-us/library/dd169357.aspx
System.IO.Path.Combine()
This class has many members related to Path manipulation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With