How to change the atributes of files?

Hi everyone,

I’m trying to change the atributes of excel files from “readonly” to “normal” so I can overwrite the files.

So far I got this:

For each file in files
assign: file = File.setatributes(file,FileAtributes.Normal)
(for each loop is set to String)

It says Setatributes is not a member of String.

There was a visual basic rename file method available instead of this you can use “Move Activity” with the same file location but with other name in destination property. It will replace old file.

1 Like

Setattributes is not a function, it wont return file for you…
You can use Invoke Method activity instead.

The thing is the name of the file must be the same. I also don’t understand how the old file can be replaced when the name of the new is diffrent. Lastly, if you use move activity with overwrite enabled it doesn’t overwrite, because the file is set to “read only” and therefore protected.

Hi bcorrea,

how can I do this with invoke method ?

image
But in your case i dont understand if it is the best way to go…

1 Like

thank you for your help. this explains a lot.
is the line of code I used correct ?

It is not correct…

why is it incorrect ?
if I do it your way it works right ? but I have to replace “c:\myfile.txt” with the “file” variable in this case right ?

Hi ,
Here is an activity FileReadOnly , It will change the file read only property.

Thank you
Balamurugan.S

2 Likes

Hi Balamurugan,
thank you very much! I will look into it.
edit: I just tried the package, works great!

P.S. if anyone knows how to code this right (without using an activity-) please post your solution. I would also like to learn to code this.

yes, ofc you need to point to the file you want to change the attribute for… you dont need to install anything else.

I can’t make it work.

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