Share via


find path bin\Debug

Question

Friday, May 3, 2013 9:48 AM

Hi,

" bin\Debug\Name.text" file should be reached also after creating Instillation program should be find file.

Best regards 

All replies (2)

Friday, May 3, 2013 10:11 AM ✅Answered | 1 vote

You need first learn apps path via any of them :

AppDomain.CurrentDomain.BaseDirectory
Assembly.GetExecutingAssembly().Location
System.IO.Directory.GetCurrentDirectory()
Application.ExecutablePath 

Then you can access  your file like :

Path.Combine( AppDomain.CurrentDomain.BaseDirectory , "name.text")
Path.Combine(Path.GetDirectoryName( Assembly.GetExecutingAssembly().Location) , "name.text")

Friday, May 3, 2013 12:17 PM ✅Answered

Hi Kahn_, I am not sure what you want to do but if you want to add a file in your project that you can use, you can try this, it worked for me:

You can create a folder in your solution (Solutons Explorer) and place that file and it can be easily accessed i.e

For example you create a folder named Files and place that file in it, then your path will be:

@"..\\.\Files\Name.text"

using it with FileInfo would be:

FileInfo file = new FileInfo(@"..\.\Files\Name.text");