Directory 在vb.net中,从字符串到long类型的转换无效错误

Directory 在vb.net中,从字符串到long类型的转换无效错误,directory,vb.net-2010,Directory,Vb.net 2010,限制特定用户对文件夹的访问。在变量am中使用vb.net.am传递用户名和pwd。但是在那一行,我得到了上面提到的错误。变量mailid和pwd包含一些值,比如xx和yy code ---- Dim FolderPath As String = "D:\ABC\2011\TAccount\HA\" 'Specify the folder here Dim UserAccount As String = mailid \ pwd Dim FolderInfo As IO.DirectoryIn

限制特定用户对文件夹的访问。在变量am中使用vb.net.am传递用户名和pwd。但是在那一行,我得到了上面提到的错误。变量mailid和pwd包含一些值,比如xx和yy

code
----
Dim FolderPath As String = "D:\ABC\2011\TAccount\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))

 FolderInfo.SetAccessControl(FolderAcl)

尝试将您的线路更改为以下

Dim UserAccount As String = mailid & "\" &  pwd
基本上,我可以理解它是把你的字符串声明作为一个和,试图用pwd除以mailid,所以它认为它是一个字符串,并试图把它转换成一个数字