Relative Path To Absolute Path in VB .NET
Posted
by Mehdi Anis
on Stack Overflow
See other posts from Stack Overflow
or by Mehdi Anis
Published on 2010-04-07T02:12:10Z
Indexed on
2010/04/07
2:43 UTC
Read the original article
Hit count: 637
Hi, I am writing a VB .NET console app where it spits takes relative path and spits out all file name, or error for invalid input. I am havinf trouble getting PhysicalPath from RelativePath
Example: ` 1. I am in folder: C:\Documents and Settings\MehdiAnis.ULTIMATEBANGLA\My Documents\Visual Studio 2005\Projects\SP_Sol\SP_Proj\bin\Debug
My App SP.exe is also in the same folder
I run: "SP.exe ..\" OutPut will be a list of all files in the folder of "C:\Documents and Settings\MehdiAnis.ULTIMATEBANGLA\My Documents\Visual Studio 2005\Projects\SP_Sol\SP_Proj\bin"
I run: "SP.exe ..\..\" OutPut will be a list of all files in the folder of "C:\Documents and Settings\MehdiAnis.ULTIMATEBANGLA\My Documents\Visual Studio 2005\Projects\SP_Sol\SP_Proj"
I run: "SP.exe ..\..\..\" OutPut will be a list of all files in the folder of "C:\Documents and Settings\MehdiAnis.ULTIMATEBANGLA\My Documents\Visual Studio 2005\Projects\SP_Sol" `
Currently I am Handling 1 relative path, but not more than one:
If Source.IndexOf("..\") = 0 Then
Dim Sibling As String = Directory.GetParent(Directory.GetCurrentDirectory()).ToString()())
Source = Source.Replace("..\", Sibling)
End If
How can I easily handle multiple ..\ easily ? Thanks.
© Stack Overflow or respective owner