Click here to Skip to main content
15,915,869 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: How to hide the startup form Pin
Naji El Kotob31-Jul-07 1:10
Naji El Kotob31-Jul-07 1:10 
AnswerRe: How to hide the startup form Pin
Joseph Guadagno31-Jul-07 9:47
Joseph Guadagno31-Jul-07 9:47 
Questionslider and the ruler Pin
eyes200730-Jul-07 21:02
eyes200730-Jul-07 21:02 
AnswerRe: slider and the ruler [modified] Pin
Tom Deketelaere30-Jul-07 21:23
professionalTom Deketelaere30-Jul-07 21:23 
GeneralRe: slider and the ruler Pin
eyes200731-Jul-07 1:15
eyes200731-Jul-07 1:15 
GeneralRe: slider and the ruler Pin
Tom Deketelaere31-Jul-07 1:32
professionalTom Deketelaere31-Jul-07 1:32 
Questionhow can i add groups to sharing folder using vb.Net Pin
koolprasad200330-Jul-07 20:20
professionalkoolprasad200330-Jul-07 20:20 
AnswerRe: how can i add groups to sharing folder using vb.Net Pin
The Man from U.N.C.L.E.31-Jul-07 8:23
The Man from U.N.C.L.E.31-Jul-07 8:23 
You will need the following Imports statements in your class:
Imports System.Security.AccessControl
Imports System.IO
Imports System.Reflection


Then, the following code would add the "Users" Group to the Sharing on the Folder containing your Application. For other folders just set the appropriate value for the Location variable and set the user variable to the group or user you wish to add.
However, a cautionary note. You will need Local Admin rights to run this code.

Try
  Dim user As String = "Users"
  Dim location as String = Path.GetDirectoryName(Assembly.GetExecutingAssembly.Location)
  Dim rule As FileSystemAccessRule 
  rule = New FileSystemAccessRule(user, _
    FileSystemRights.FullControl, _
    InheritanceFlags.None, _
    PropagationFlags.NoPropagateInherit, _
    AccessControlType.Allow)
  Dim security As  DirectorySecurity = Directory.GetAccessControl(location)

  Dim modified as Boolean = false
  security.ModifyAccessRule(AccessControlModification.Set, rule, modified)

  rule = New FileSystemAccessRule(user, _
    FileSystemRights.FullControl, _
    InheritanceFlags.ContainerInherit OR InheritanceFlags.ObjectInherit, _
    PropagationFlags.InheritOnly, _
    AccessControlType.Allow)

  modified = false
  security.ModifyAccessRule(AccessControlModification.Add, rule, modified)

  Directory.SetAccessControl(location, security)

Catch ex As Exception

End Try


I used this in a Custom Installer Action, but now I have changed to using WIX to write my installers, which has custom actions to set folder security built in.


If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)

GeneralRe: how can i add groups to sharing folder using vb.Net Pin
koolprasad20031-Aug-07 3:06
professionalkoolprasad20031-Aug-07 3:06 
QuestionVoice Recognition Pin
Ashraf zia30-Jul-07 20:00
Ashraf zia30-Jul-07 20:00 
AnswerRe: Voice Recognition Pin
Christian Graus30-Jul-07 20:21
protectorChristian Graus30-Jul-07 20:21 
Questionwindow application deployment problem Pin
Sonia Gupta30-Jul-07 19:37
Sonia Gupta30-Jul-07 19:37 
AnswerRe: window application deployment problem Pin
Christian Graus30-Jul-07 20:22
protectorChristian Graus30-Jul-07 20:22 
QuestionControl to display a merge cell Pin
Mekong River30-Jul-07 16:06
Mekong River30-Jul-07 16:06 
AnswerRe: Control to display a merge cell Pin
Dave Kreskowiak31-Jul-07 2:45
mveDave Kreskowiak31-Jul-07 2:45 
GeneralRe: Control to display a merge cell Pin
Mekong River31-Jul-07 14:53
Mekong River31-Jul-07 14:53 
QuestionTable Question Pin
nlindley730-Jul-07 8:25
nlindley730-Jul-07 8:25 
AnswerRe: Table Question Pin
Dave Kreskowiak30-Jul-07 8:45
mveDave Kreskowiak30-Jul-07 8:45 
GeneralRe: Table Question Pin
leckey30-Jul-07 9:26
leckey30-Jul-07 9:26 
GeneralRe: Table Question Pin
Dave Kreskowiak30-Jul-07 9:44
mveDave Kreskowiak30-Jul-07 9:44 
JokeRe: Table Question Pin
Paul Conrad30-Jul-07 11:11
professionalPaul Conrad30-Jul-07 11:11 
QuestionSelect from a DataTable in VB.NET Pin
MohammadAmiry30-Jul-07 8:06
MohammadAmiry30-Jul-07 8:06 
AnswerRe: Select from a DataTable in VB.NET Pin
nlindley730-Jul-07 8:31
nlindley730-Jul-07 8:31 
GeneralRe: Select from a DataTable in VB.NET Pin
MohammadAmiry30-Jul-07 9:08
MohammadAmiry30-Jul-07 9:08 
GeneralRe: Select from a DataTable in VB.NET Pin
nlindley730-Jul-07 9:25
nlindley730-Jul-07 9:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.