How to call a class method to modify the file permissions?

Now I want to use this method to modify the file permissions, but do not know how to use this “Invoke method” can help me? Or is there any better way?

System.IO.File.SetAttributes (“C: \ test.txt”, _
attr And (Not System.IO.FileAttributes.ReadOnly))1

Hey @zhulong644

There is a more simpler way available use that :slight_smile:. It works for me :slight_smile:

System.IO.FileInfo fileinfo =new System.IO.FileInfo(“E:\Test.txt”); // use assign activity. :slight_smile:

fileinfo.IsReadOnly= True; // use assign activity :slight_smile:

It will set up the file permission to read only mode.

or other attributes also you can modify like below :slight_smile:

fileinfo.Attributes = System.IO.FileAttributes.Hidden //"you can replace the Hidden property with the supported properties :slight_smile:

Regards…!!
Aksh

2 Likes

Thank you very much! It is work for me!

Hi there, I am just starting out on UiPath and have tried to understand how the solution proposed by aksh1yadav would look like in UiPath’s interface.

I’m not at all familiar with the Invoke method - could I ask how I can put together the necessary components so that UiPath can automatically set my file attribute to readonly? Would be great if someone can share the .xaml file for this step.

Many thanks in advance…