How to create folder with read access only using uipath

Task is like , creating new folder which contain read access to all except robot.
so that any file store inside this folder will remain read only

@TUSHAR_DIWASE

Check this thread,It might helps you

Hope it helps!!

New-Item -ItemType Directory -Path “C:\Path\to\your\folder”
$acl = Get-Acl “C:\Path\to\your\folder”
$permission = “Everyone”,“Read”,“Allow”
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
$acl.SetAccessRule($accessRule)
Set-Acl “C:\Path\to\your\folder” $acl

Imports System.IO

Public Class Main
Public Sub CreateReadOnlyFolder()
Try
’ Specify the path for the folder
Dim folderPath As String = “C:\Path\To\Your\Folder”

        ' Check if the folder doesn't exist, then create it
        If Not Directory.Exists(folderPath) Then
            Directory.CreateDirectory(folderPath)

            ' Set the folder attributes to read-only
            Dim folderInfo As New DirectoryInfo(folderPath)
            folderInfo.Attributes = folderInfo.Attributes Or FileAttributes.ReadOnly

            ' Display a message indicating successful creation
            Console.WriteLine("Folder created successfully and set to read-only.")
        Else
            ' Display a message if the folder already exists
            Console.WriteLine("Folder already exists.")
        End If
    Catch ex As Exception
        ' Display any error that occurs
        Console.WriteLine("An error occurred: " & ex.Message)
    End Try
End Sub

End Class

Imports System.IO

Public Class Main
Public Sub CreateReadOnlyFolder()
Try
’ Specify the path for the folder
Dim folderPath As String = “C:\Path\To\Your\Folder”

        ' Check if the folder doesn't exist, then create it
        If Not Directory.Exists(folderPath) Then
            Directory.CreateDirectory(folderPath)

            ' Set the folder attributes to read-only

icacls “C:\Users\Username\Documents\TestFolder” /grant:r “*S-1-1-0:(R)”

Imports Spire.Xls

Namespace PasswordProtectWorkbook
Class Program
Shared Sub Main(ByVal args() As String)
'Create a Workbook object
Dim workbook As Workbook = New Workbook()

        'Load an Excel file
        workbook.LoadFromFile("C:\Users\Administrator\Desktop\sample.xlsx")

        'Protect workbook with a password
        workbook.Protect("psd-123")

        'Save the workbook to another Excel file
        workbook.SaveToFile("Encrypted.xlsx", ExcelVersion.Version2016)
    End Sub
End Class

End Namespace