How to get absoulte path from relative path?

dotnet framework

    Next

  • 1. dataGrid's RowCount and ColCount property?
    Hi all, I'm searching help files but it did not help. How can I reach datagrid's row count and col count properties. Thaks a lot. Arif men
  • 2. Problem due to COleObjectFactory::UpdayeRegistryALL() fuction implementation change from VC 6.0 to 7.0
    Hi All We were using VC++ 6.0 and BOOL COleObjectFactory::UpdayeRegistryALL() used to register a list of factory objects for the COM server. In VC 7.0 the same function call does not register all the exposed interfaces. On closer investigation I found that: In a list of eight factory objects which were to be registered in the function call COleFactoryObject::UpdayeRegistryALL() whenever the clsid of the exe, which is an automation server, is encountered the UpdateRegistry call returns FALSE and the rest of the factories did not get registered. This is a major change from VC 6.0 in which UpdateRegistry function never returned FALSE whether or not it registered a particulate Interface. What should I do to register my factories? Regards AK

How to get absoulte path from relative path?

Postby Ilya Evseev » Sun, 04 Jul 2004 10:46:36 GMT

    Hi!
Consider string containing relative path,
may be with "\..\"and "\.\", with or without drive name, etc.

I looking for API routine that converts that arbitrary filepath to full
path,
based on current drive, current directories on all drives
and (bingo!) on any other filepath that is used as starting point.

Example: starting point = "d:data\configs\conf1.txt",
filepath = "..\images\img1.gif",
result = "d:\current-directory\data\images\img1.gif"

It should be something like FExpand function from Borland Pascal RTL
and fnmerge() from POSIX API.

Thanx in advance,
Ilya



Re: How to get absoulte path from relative path?

Postby Michael Giagnocavo [MVP] » Tue, 06 Jul 2004 05:30:02 GMT

Hi there,

System.IO.Path.GetFullPath(System.IO.Path.Combine(@"d:\data\configs\conf1.txt", 
@"..\images\img1.gif"));
gives us:
"d:\\data\\configs\\images\\img1.gif"

Look at the Path class, since with a few calls you can get what you're 
looking for.

-mike
MVP








Similar Threads:

1.why relative hint path but absolute reference path

I have a vs.net 2002 solution that contains a number of projects
All projects are created in folders under the solution folder.
The idea here is that this entire solution should be 'moveable' ie. copied
to and useable from a new directory or computer.
And it almost is.

One project makes reference to an existing .net dll that also exists in a
folder under the solution folder.
The project file shows a relative hint path to the dll ie
"..\..\dllFolder\my.dll"
If I move the solution to a new folder and the open solution from the new
location, the dll can no longer be found.  if i restore the original
solution folder, the dll is once again found.  so obviously, although the
project file includes a relative hint path, vs.net is in fact looking for
the dll at an absolute location.  This is causing headaches as this solution
cannot be 'passed around'  without re-adding the reference to this dll.

is there some setting somewhere to get the relative path used ?
there does not seem to be any problem using relative project references - is
there some trick using a dummy project to get this to work ?

gerry



2.Get machine name path from relative or absolute path

Hello, is it possible in C#.Net to get a path to a file in the form
"\\Spain\Madrid\readme.txt" from a relative path i.e "readme.txt" or
from a absolute path in the following form "C:\Madrid\readme.txt" where
"Spain" is the name of the machine that the file is on? Thanks in
advance.

3.absolute path to relative path conversion

4.why relative hint path but absolute reference path

I have a vs.net 2002 solution that contains a number of projects
All projects are created in folders under the solution folder.
The idea here is that this entire solution should be 'moveable' ie. copied
to and useable from a new directory or computer.
And it almost is.

One project makes reference to an existing .net dll that also exists in a
folder under the solution folder.
The project file shows a relative hint path to the dll ie
"..\..\dllFolder\my.dll"
If I move the solution to a new folder and the open solution from the new
location, the dll can no longer be found.  if i restore the original
solution folder, the dll is once again found.  so obviously, although the
project file includes a relative hint path, vs.net is in fact looking for
the dll at an absolute location.  This is causing headaches as this solution
cannot be 'passed around'  without re-adding the reference to this dll.

is there some setting somewhere to get the relative path used ?
there does not seem to be any problem using relative project references - is
there some trick using a dummy project to get this to work ?

gerry






5.Project Output path converts to Relative path automatically

Hello there,

In the project configuration properties, whenever I change the
Build/Output path to a absolute path and close the window and If I go
there again I see it is automatically changed to a relative path. But I
want my project output to be a specific folder irrespective of where I
keep my solution.

For eg:
if I set the output path to "C:\Program files\MyApp\Bin" and apply it.
But If I go ther again it is changed to something like
"..\..\..\MyApp\Bin".

Does anybody have any idea why this behaviour is and how to change
this???

Btw, I'm using VS.NET 2003 IDE.

6. Configuration File Location Path is a DOS path compressed path

7. There are any Path or Directory function to convert an absolute path to a relative path?

8. Relative Paths and Class Libraries



Return to dotnet framework

 

Who is online

Users browsing this forum: No registered users and 69 guest