If i have the following directory structure:
Project1/bin/debug
Project2/xml/file.xml
I am trying to refer to file.xml from Project1/bin/debug directory
I am essentially trying to do the following:
string path = Environment.CurrentDirectory + @"..\..\Project2\xml\File.xml":
what is the correct syntax for this?
string destFile = System. IO. Path. Combine(targetPath, fileName);
open System open System.IO if Environment. OSVersion. Platform = PlatformID. Win32NT then // Change the directory to %WINDIR% Environment.
Combines an array of strings into a path. Combine(String, String) Combines two strings into a path.
C# tutorial is a comprehensive tutorial on C# language. The Path is located in the System.IO namespace. With the Path class, we can easily figure out the root path, the directory name of the file, its extension or create a random file name.
It's probably better to manipulate path components as path components, rather than strings:
string path = System.IO.Path.Combine(Environment.CurrentDirectory,
@"..\..\..\Project2\xml\File.xml");
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