7
Aug/080
Aug/080
Creating File Paths in C#
Path.Combine is an easy and reliable way to combine path and file information.
Before
DataFile = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + "samplefile.xml"
After
DataFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop),"samplefile.xml");
When using Special Folders you need to call Environment.GetFolderPath to return the actual path.