Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Windows WPF VB.NET
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
C:\Users\501013\Desktop\Shortcuts\Shortcuts\bin\Debug\Images\Question-icon.png
 
but my actual path is
C:\Users\501013\Desktop\Shortcuts\Shortcuts\Images\Question-icon.png
 
Please tell me how to get the actual path
 
Thank you
Posted 7-Mar-13 1:22am
Comments
Sampath Sridhar at 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 at 7-Mar-13 7:04am
   
You should post that as the solution.
Snehasish Nandy at 7-Mar-13 6:50am
   
got it..thanks...
Rate this: bad
good
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.
  Permalink  
Rate this: bad
good
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.
  Permalink  
Rate this: bad
good
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() & "\CnSetting.cn"
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 250
1 George Jonsson 175
2 Jochen Arndt 150
3 Kornfeld Eliyahu Peter 149
4 PIEBALDconsult 110
0 OriginalGriff 6,080
1 DamithSL 4,648
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,624
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 8 Mar 2013
Copyright © CodeProject, 1999-2014
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