Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i need the path to audio files in my resources directory
Posted
Comments
Tejas Vaishnav 31-Dec-14 8:42am    
Have you try to use Application.Startup Path
john1990_1 31-Dec-14 9:32am    
yes it worked thx, answer for me to accept the answer.
Tejas Vaishnav 1-Jan-15 3:44am    
I have added a answer, so can you please accept it and rate it.
Sergey Alexandrovich Kryukov 31-Dec-14 14:09pm    
Most usually, you don't need this path. It is embedded resource or just the file copied in the sub-directory of the project's output directory? (And why?) In all cases, this is not a problem at all.
—SA

Can you please use Application.StartupPath to get current execution path of your application

By using System.Reflection and System.IO you can also find path like this...

C#
string assmblypath = Assembly.GetEntryAssembly().Location;
string appPath = Path.GetDirectoryName(assmblypath);
 
Share this answer
 
v2
You already got an answer, but I'll give you an alternative, a more universal method. Please see my past answer: How to find my programs directory[^].

Please read my explanation on why you want to prefer this way.

Now, you could totally get rid of the file location problems and dealing with files themselves if you used embedded resources via .resx resource node. You should better used "Add Existing File" for adding the resource, In this case, the file is added to the project (as a file and its reference to the project file) and the reference in the resource file; and auto-generated C# is created, with the ready-to-use static property. If the type of your resource is not known to the system, the array of byte type will be used, which you can use for reading the resource form a memory stream. It would work great, but if, of course, your audio files are not too big.

—SA
 
Share this answer
 
can you explain better please?
Anyway you can you different method like, for example.

the user can select directory --> openFolderDialog
and you can store in a file, db or when yuo want the openFolderDialog.selectedPath.

maybe that is what was you looking for
 
Share this answer
 
Comments
BillWoodruff 31-Dec-14 11:19am    
Requests for clarification from the OP should be asked as comments, not posted as a solution.
Simply you need to use:
C#
Properties.Resources.<your filename>
 
Share this answer
 
v3

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900