user123 user123 - 8 months ago 52
C# Question

How can i get current application folder path in c# windows application

I created one folder like

DownloadFile
to my application and how can i get that folder.

I took below code

string pathname = System.Environment.CurrentDirectory(Application.ExecutablePath);


by using the above code i am getting with
\\bin\\debug


I need to get my folder name
DownloadFile


Please help me out.

Thank you

Answer Source

if the DownloadFile folder is in the main folder of you project you can "go up" 2 folders from "bin\debug" and "go into" DownloadFile.

System.Environment.CurrentDirectory(Application.ExecutablePath).Replace("\\bin\\debug","\\DownloadFile");