Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET2.0 C#2.0 Windows
Hello everyone,
 
I am new in windows application and I have created one windows application. In this I want to show images from img folder which is in my project. Now how can I get the images from img folder? I tried with "Application.ExecutablePath", but it is taking path of bin\Debug directory. I put my img folder in bin\Debug folder but when I create a setup project and install it in my computer its not working.
 
Please tell me how can I take the path of the img folder in windows application using C#?
 
Thanks & Regards,
Yogesh
Posted 7-Sep-11 8:12am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Here is my detailed answer to a very similar question: how to get image in picturebox from existing Solution explorer Folder in windows application[^].
 
—SA
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

u use this line
string path =System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)
to get application path
& in the start of application check if your image folder is not exists create it
if (!Directory.Exists(path + @"\Images"))
{
Directory.CreateDirectory(path+ @"\Images");
}
so when you creat u setup project no problem
every time u open your solution it check for folder path
  Permalink  
v2
Comments
Dalek Dave at 14-Sep-11 3:22am
   
Good Call.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Public Function App_Path() As String
     Return System.AppDomain.CurrentDomain.BaseDirectory()
 End Function
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 7

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Yogesh,
 
When you create your setup project, consider placing the image folder someplace that is 'known', such as c:\ProgramData\YogeshApp\img\ (for Vista and Windows 7). Then you can hard code the path.
 
The code below will take you to your 'known' folder on XP/Vista/7. Use the same notation for installations.
 
string imagesFolder = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\YogeshApp\\img\\";
 
Hogan
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

In code behind file write the following code
 
string filepath=AppDomain.CurrentDomain.BaseDirectory+"\images";
 
and use filepath variable at the place where you want access images folder
  Permalink  

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

  Print Answers RSS
0 George Jonsson 175
1 Kornfeld Eliyahu Peter 169
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 14 Sep 2011
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