473,385 Members | 1,275 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

create shared new directory

I need to create a folder in code, and also set sharing to being shared to
everyone with full control (or some such variation of security)

What I'm doing now is:

If Not System.IO.Directory.Exists(My.Application.Info.Dir ectoryPath &
"\NewTestFolder") Then

System.IO.Directory.CreateDirectory(My.Application .Info.DirectoryPath &
"\NewTestFolder")

End If

It appears there is a second parameter to the .CreateDirectory method, but
the type of "directorysecurity" which definitely sounds promising, but
trying to determine how to use this is proving a bit of a challenge.
Apr 7 '07 #1
1 3438
Hi Matt ,

If you want to configure the DACL of the directory to allow everyone on
your machine to full control this folder, then you are looking at the
correct parameter. The "DirectorySecurity Class" below contains the sample
code regarding how to setup the DirectorySecurity object:
http://msdn2.microsoft.com/en-us/lib...scontrol.direc
torysecurity.aspx

The link below also contains some ACL programming stuff:
"How To Program ACLs"
http://pluralsight.com/wiki/default....ProgramACLs.ht
ml

However, if you want to share this directory with others from remote
computer through LAN file share, there is another story.

In file share, there are 2 stages of access check: DACL access check and
file share permission check. Only account authentication can pass these 2
permission sets stages, can it successfully access the shared files.

Sharing Permission set can be configured through "Permissions" button in
"Sharing" tabpage in folder property dialog, while NTFS DACL Permission set
can be configured through button in "Security" tabpage in folder property
dialog.

..Net contains build-in support to configure the DACL permission of
directories/files and I have shown you the sample code snippet in the first
paragraph. To configure the share permission, there is no build-in support.
We have to p/invoke NetUseAdd Win32 API for this task. My original reply
below and the codeproject article demonstrates this idea with code snippet
in C#:
http://groups.google.com/group/micro...curity/msg/063
d7b08b29e5642?hl=zh-CN&
"How to create a file share using .NET framework"
http://www.codeproject.com/dotnet/pinvokeaddshare.asp

Finally, the article below contains very detaild ACL programming in
..Net2.0, it should be informative if you are curious about security
programming in .Net:
http://www.codeproject.com/csharp/accessctrl3.asp

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 9 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Chris | last post by:
I try to read a shared directory. This shared directory is on a 2000 server. When I use DirectoryInfo.Exists, I always have "This directory does not exist". If the shared directory is on a...
2
by: Mickey | last post by:
When I try to create a new web application in VS Studio .NET 2003 at a simple default location eg: http://localhost/WebApplication1 I get the following error: Visual Studio .NET cannot create or...
11
by: Andre | last post by:
Hi, I have ASP.NET application running on standalone (not part of the domain) Windows 2003. I use forms authentication for my application. The problem I have is that I need to create and read...
27
by: Javier Martinez | last post by:
Hi I have asp application in a machine with a virtual directory referring a shared directory in another machine When I try to load any aspx page of my portal I get the following error: ...
2
by: yxq | last post by:
Hello I want to create and delete the folder share, i found that it is ok for generic folder, but it does not work for Root directory(i.e c:\, d:\) The code...
0
by: Greg Conely via .NET 247 | last post by:
I am creating a application that will be using plugins. I am doing this so that when I want to let this application work with another type of dbase system, I only have to write\install one plugin,...
2
by: Paul Bromley | last post by:
How can I create a directory within a shared ntwork directory?? sServerName - is the Server name "\Docs" - is the shared directory "\Others" - is the directory to create. The following...
2
by: §iD` | last post by:
Hi! I would like to create a virtual folder (which I want to mount) and populate managing his content by a DLL or something like that in VB.NET (2.0). How can I acomplish this? Thanks to...
6
by: jzdeng | last post by:
Hi, All I use VS 2005 to create a web service. The web service is used to create a sheared folder. It works fine we I run it from VS 2005. But, when I move it to inetpub, it does not work...
1
by: Claire | last post by:
Ive written a small string resource building utility that I send out to our translators. I have a setup project for each language we support, which picks out a group of 12 english resx files plus...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.