Hi,
I want to download a file from google into a particular folder and save it with a particular name. Can anyone help on the same with a solution?
Please refer to the attached Screenshot.
Regards,
Sarah
Hi,
I want to download a file from google into a particular folder and save it with a particular name. Can anyone help on the same with a solution?
Please refer to the attached Screenshot.
Regards,
Sarah
Hi,
You can download using HREF,
Get the HREF of your file which you want to download it from google using âGet attributeâ activity and store it into one variable, in here i am storing my href into âdownloadaudioâ variable
Add this code into Invoke code acitivity
Using wc As New System.Net.WebClient()
wc.DownloadFile(Url,Path)
End Using
Make sure you are passing same arguments in your codeâŚ
4) Pass your HREF variable into URL arguments value and set your desire path into PATH arguments value
Hope this will work for you
Regards,
Vinit M
Hi, Sarah! Welcome to the community.
Can you explain your task in more detail?)
Hi @Sarah_Syed welcome to UiPath Forum
Please find below link for reference to go to download settings in chrome
So I understand you are downloading something from Google
So in download settings there will be an option named :Ask where to save the file everytime
Kindly enable that radio button so you will be able to download the file to your desired destination location
Thanks @nikhil.girish .
Thanks @Vinit_Mhatre , thatâs something new to me!
Hi @Sergey_Petrenko ,
The process is that I have to generate some document from Google and save it in a particular folder in âDownloadsâ.
"This PC\Downloads\Extract1\Extract UiPath1"
But the problem is Iâm unable to give the path in the Save As - window using UiPath Studio Activities. (Even after enabling âAsk where to save the file everytimeâ in Google settings)
Regards,
Sarah
Please try to insert path to âFile nameâ field.
C:\This PC\Downloads\Extract1\Extract UiPath1\file.pdf
And then click âSaveâ.
Hello,
Great response, works for me and looks like an elegant way to achieve this goal. One more question for me, can the code be modified to create a folder if it doesnât exist?
Hello @Tadas - Is it not creating the folder if it doesnât exists??
Hi,
No it throws an error for me⌠if I assign a path with just a file name it downloads it to my project folder. workflow attached
DownloadFile.xaml (10.3 KB)
RemoteException wrapping System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. â> RemoteException wrapping System.Net.WebException: An exception occurred during a WebClient request. â> RemoteException wrapping System.IO.DirectoryNotFoundException: Could not find a part of the path âC:\Users\xxxxx\new\new.docxâ.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStreamâŚctor(String path, FileMode mode, FileAccess access)
at System.Net.WebClient.DownloadFile(Uri address, String fileName)
â End of inner exception stack trace â
at System.Net.WebClient.DownloadFile(Uri address, String fileName)
at System.Net.WebClient.DownloadFile(String address, String fileName)
at UiPathCodeRunner_b8c7bddc7cc942b6af5b8475b95614e2.Run(String url, String Path)
â End of inner exception stack trace â
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object parameters, Object arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object providedArgs, ParameterModifier modifiers, CultureInfo culture, String namedParams)
at UiPath.Activities.System.Utilities.InvokeCode.CompilerRunner.Run(Object args)
at UiPath.Activities.System.Utilities.InvokeCode.NetCodeInvoker.Run(String userCode, List1 inArgs, IEnumerable
1 imps, Object args)
at UiPath.Core.Activities.InvokeCode.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)
Before saving the file, youâd have to use an If with NOT Directory.Exists(yourPath) as the condition, and then in the Then you create the folder. Again, do this before you click whatever youâre clicking to download the file.
Hi @Vinit_Mhatre,
I tried your suggestion but getting the below error. Can you check and advise?
âInvoke code: Exception has been thrown by the target of an invocation.â
Kind regards,
Karunamurthy
Try printing your arguments; this error occurs when the arguments contain blank data.
Regards,
Vinit
Hi @Vinit_Mhatre,
Sorry, I am unable to understand âTry printing your argumentsâ. Can you please elaborate it further?
I want the text file to be downloaded from the âBrowserâ to particular folder âData\Outputâ.
Thank you for the help!
Kind regards,
Karuna
What if you donât find Href attribute in my case equals #