Click here to Skip to main content
13,091,134 members (93,314 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all

i wrote the below code to get the path for a image

p = Path.GetFullPath("Images\Question-icon.png")

its returning me the path as

but my actual path is

Please tell me how to get the actual path

Thank you
Posted 7-Mar-13 0:22am
Sampath Sridhar 7-Mar-13 6:35am
There could be duplicate image in Debug folder.
Please check and delete that.
Otherwise check as follows:
<pre lang="c#"> p = Path.GetFullPath("..\..\Images\Question-icon.png")</pre>
ryanb31 7-Mar-13 7:04am
You should post that as the solution.
Snehasish Nandy 7-Mar-13 6:50am
got it..thanks...
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Posting it to pop it our of unanswered list. OP commented that it is resolved now.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

It's giving you the Debug path because that's the current directory as far as your running .EXE is concerned. It's NOT going out and actually trying to find the file for you. It just manipluates path spec's without evern touching the file system or looking at any files to see if they exist or not.
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

 Public Function MyPath() As String
    Dim sPath As String = Application.ExecutablePath
    sPath = System.IO.Path.GetDirectoryName(sPath)
    If sPath.EndsWith("\bin\Debug") Then
        sPath = sPath.Substring(0, Len(sPath) - 10)
    ElseIf sPath.EndsWith("\bin\Release") Then
        sPath = sPath.Substring(0, Len(sPath) - 12)
    End If
    Return sPath
End Function

using Mypath

Dim fName As String = MyPath() & "\"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170813.1 | Last Updated 8 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100