Dynamically creating file paths in .Net

Is there an easy way to dynamically create a file path in .NET? At the moment I am creating a file path by combining various lines (from application settings, user input and Date.ToString), but this depends on the fact that the lines do not contain double characters \ or invalid characters, etc. Obviously, I can manually check the strings for this kind of thing, but I was wondering if there was something built into .Net that could handle this.

+4
source share
2 answers

Use Path.Combine

Dim p = Path.Combine(somePath, "foo\bar") 

Documentation: http://msdn.microsoft.com/en-us/library/dd169357.aspx

+10
source

System.IO.Path.Combine ()
This class has many members involved in traffic manipulation.

+3
source

All Articles