Facing the issue on Upload files of Microsoft 365 Scope?

Hi All,

I am trying to upload the files from local folde into the sharepoint folder.
Under microsoft 365 scope activity, I have used for each activity, Argument type as System.collections.Generic.IEnumerable<UiPath.Platform.ResourceHandling.IResource>

Then Used Upload files of microsoft 365 scope activity under For each.

Please check the screenshot Facing the issue on For Each Type

Can some one help me on this please

@TJamuna

in upload files activity try to give your input with below syntax

LocalResource.FromPath(CurrentIEnumeratorOFText)

or

when getting your files from directory use
use below syntax in Assign activity

Directory.GetFiles(“Path”).Select(function(x) LocalResource.FromPath(x)).ToArray

delete existing for each take one new for each then give new array variable,
then you can directly use currentitem without above syntax

happy Automation

@TJamuna

Try converting local file to IResource using this

UiPath.Platform.ResourceHandling.LocalResource.FromPath(currentIEnumeratorOfText))
1 Like

@yedukondaluaregala Thanks for the reply

I am facing issue, When i use Directory.GetFiles(“Path”).Select(function(x) LocalResource.FromPath(x)).ToArray


Please guide me. Thanks

@TJamuna

Please change the type of variable, from Array of string to Array of ILocalResource.

to find that variable type, go to the variable section select array in that select browse for types in that search ILocalResource.



And one more thing,

instead of getting files from the folder and assigning to the folder after that using loop.

you can use For Each File In Folder
here you can simply all above steps by using this one activity

Happy Automation!!

@yedukondaluaregala Thanks for the reply

I have changed the variable.
Now I am getting error on upload file activty from Files. Do i need to change argument type in the for each here please guide me.

Can you use For each file in Folder Activity

@yedukondaluaregala

Do i need to apply any syntax in upload files. I have tried with For each file in folder
Please let me know

@TJamuna,

No need to iterate. You can pass array of file path like this.

fileArray.Select(Function(filePath) UiPath.Platform.ResourceHandling.LocalResource.FromPath(filePath)).ToList()

1 Like

Sorry for distraction and troubling

follow below steps

  1. Use Assign activity, to store the files. Variable type array of string
    2.use for each dont change any argument, just check whether argument type is string or not.
    if not change to string.
    3.Use upload file activity
    4.Click on + icon of file(s) section
  2. select build a collection of files
  3. Then the field acceptance will change
  4. Now click on file(s) field
  5. now enter LocalResource.FromPath(currentText)

i am giving snaps for your more reference,


Uploading: image.png…

1 Like

This is also provided the solution. Thanks @ashokkarale

Thanks @ashokkarale
This also providing the solution.

@TJamuna,

That would be static solution with fixed number of files. Mine will be a dynamic one. If change in the number of file, won’t require any code change but whatever works for you is the best.

Cheers!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.