How to get the full path of a directory by using it's name?



I want to check for a specific file in Downloads directory and delete it if it exists?
Someone please tell me how to get the full path of “Downloads” directory? Because If I use the full path, it doesn’t work when others use the same code, they need to change the path again.

Thanks and Regards,



The full path can be something like below.

The user name can be taken as a variable, if different user log in, his username value can be given in the full path.

Saranya K R

Dynamic Path

You can find all special folder using the below code, it gives the user desktop path.

But Download Path is not treated as special folder so you can try below code



@Bharat, Environment.ExpandEnvironmentVariables("%USERPROFILE%\Downloads") this one worked.

Thanks a ton :slight_smile:


Thanks a lot for the solution @SaranyaKishore. Currently used the suggestion provided by @Bharat. But definitely your solution will be helpful in future :slight_smile:


But I am getting one more problem in this. Suppose if store the path in a variable say "downloadDirPath. then using directory.GetFiles(downloadDirPath) doesn’t give the list of files. Instead it prints the System.string[]. Actually now I want to list out all the files and search the specific file out of those.


directory.GetFiles(downloadDirPath) will store the filenames in an array.
Use a for each loop to access all the files.




Thanks a ton, it worked.