Open a downloaded file

Ask general questions here.
asishr
Posts: 4
Joined: Tue Mar 27, 2018 3:24 pm

Open a downloaded file

Post by asishr » Wed May 02, 2018 5:30 pm

I am trying to download a file from Chrome and open it from my Downloads folder to verify it. Can we launch the file explorer similar to a browser launch instead of going by the UI as the location of File Explorer can be varied in different environments. Using code module. Thanks in advance.

McTurtle
Posts: 191
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: Open a downloaded file

Post by McTurtle » Thu May 03, 2018 11:39 am

Hello asishr,

I found the solution on stackoverflow under the following link: How can I open Windows Explorer to a certain directory from within a WPF app?

However, if you want it to be independent of the username, then you need to get the username independently:
public void StartFileExplorer()
        {
        	string username=Environment.UserName;
        	Process.Start(@"C:\Users\"[email protected]"\Downloads");
        }
I hope this helps.

Regards,
McTurtle

asishr
Posts: 4
Joined: Tue Mar 27, 2018 3:24 pm

Re: Open a downloaded file

Post by asishr » Thu May 03, 2018 3:03 pm

I did looked up in stack but probably was not searching for correct context. Your solution worked like a charm. Thank you