Hello ,i have a function which combine path.
Example
My application is located in D:\toto\titi\tata\myapplication.exe
And I create a windows form application(c#) which solve the relative path based on the path of my application (D:\toto\titi\tata\myapplication.exe).
I want to this this :
1)Path to resolve is test.txt => D:\toto\titi\tata\test.txt
2)Path to resolve is .\..\..\test\test.txt => D:\toto\test\test.txt
3)Path to resolve is .\..\test\test.txt => D:\toto\titi\test\test.txt
4)Path to resolve is .\..\..\..\test\test.txt => D:\test\test.txt
5)Path to resolve is .\..\..\..\..\test\test.txt => The path doesn't exist
6)Path to resolve is \\server\share\folder\test => get the corresponding path in the server.
I use this method
private void btnSearchFile_Click(object sender, EventArgs e)
{
// Open an existing file, or create a new one.
FileInfo fi = new FileInfo(@"D:\toto\titi\tata\myapplication.exe");
// Determine the full path of the file just created or opening.
string fpath = fi.DirectoryName;
// First case.
string relPath1 = txtBoxSearchFile.Text;
FileInfo fiCase1 = new FileInfo(Path.Combine(fi.DirectoryName, relPath1.TrimStart('\\')));
//Full path
string fullpathCase1 = fiCase1.FullName;
txtBoxFoundFile.Text = fullpathCase1;
}
but i doesn't solve point 1);point 5) and point 6)
Can you help me
Loading
lelo nyakaPosted Feb 9, 2015, 11:02 AM
var s3 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..\test\test.txt");I give me the root of my application in visual studio.
Have you idea for these points :
5)Path to resolve is .\..\..\..\..\test\test.txt => The path doesn't exist
6)Path to resolve is \\server\share\folder\test => get the corresponding path in the server.(unc path)
how to implement it
Anupam SinghPosted Feb 9, 2015, 10:51 AM
lelo nyakaPosted Feb 9, 2015, 9:35 AM
Thanks.
Anupam SinghPosted Feb 9, 2015, 9:32 AM