Reputation: 1367
using vb.net set denied access to a particular folder.here i attached my code . but am getting error in my code like covert from string to type long is not valid
code
-----
Dim ds1 As New TdeskTableAdapters.proc_checkuserrightsTableAdapter
Dim dt1 As Tdesk.proc_checkuserrightsDataTable = ds1.GetData(ecode)
For Each r1 As DataRow In dt1.Rows
reqrights = r1("fld_reqrights").ToString
approv_rights = r1("fld_approval").ToString
Next
If approv_rights = "n" Or approv_rights = "N" Then
Dim FolderPath As String = "D:\Account\HA\" 'Specify the folder here
Dim UserAccount As String = mailid \ pwd
Dim FolderInfo As IO.DirectoryInfo = New IO.DirectoryInfo(FolderPath)
Dim FolderAcl As New DirectorySecurity
FolderAcl.AddAccessRule(New FileSystemAccessRule(UserAccount, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit Or InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Deny))
'FolderAcl.SetAccessRuleProtection(True, False) 'uncomment to remove existing permissions
FolderInfo.SetAccessControl(FolderAcl)
End If
getting error in this line
Dim UserAccount As String = mailid \ pwd error mentioned in the above
Upvotes: 0
Views: 366
Reputation: 460158
So etiher mailid
or pwd
is a Long
and the other is a String
.
I assume that mailid
is a Long
:
Dim UserAccount As String = mailid.ToString() & "\" & pwd
But if you use &
to concatenate strings you can also omit the ToString
.
Another readable way is using String.Format
which also converts implicitely to string:
Dim UserAccount As String = String.Format("{0}\{1}", mailid, pwd)
Upvotes: 1