Reputation: 213
I am using WatIn making login to webSite and downloading file.I dont have to much power on download dialog sow when i see download dialog i just press save button and file downloading to defaul folder of broser,AND this is exactly what i need the path to this folder.I know that basicly it C:\Users\UserNAme\Favorites\Downloads
but i need to bee 100% sure because user can change this path.
How to find last downloaded file path or the default download folder of broser.
here my code for download if any one need
Thread.Sleep(10000);
IntPtr prevChild = FindWindow("IEFrame", "Reports | ACCESS - Internet Explorer");
Thread.Sleep(3000);
IntPtr currChild = FindWindowEx(prevChild, 0, "Frame Notification Bar", "");
Thread.Sleep(3000);
IntPtr currChild2 = FindWindowEx(currChild, 0, "DirectUIHWND", "");
Thread.Sleep(3000);
PostMessage(currChild2, WM_KEYDOWN, VK_F6, 2);
Thread.Sleep(3000);
PostMessage(currChild2, WM_KEYDOWN, VK_TAB, 2);
Thread.Sleep(3000);
PostMessage(currChild2, WM_KEYDOWN, VK_ENTER, 2);
Upvotes: 1
Views: 14140
Reputation: 769
IE 11: default it will go to %homedrive%%homepath%\downloads or %userprofile%\downloads - result is the same. If its not default there will be a REG_SZ value with name 'Default Download Directory' in key 'HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main'
EDIT:
String path = String.Empty;
RegistryKey rKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Internet Explorer\Main");
if (rKey != null)
path = (String)rKey.GetValue("Default Download Directory");
if (String.IsNullOrEmpty(path))
path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\downloads";
Upvotes: 4