473,418 Members | 2,640 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,418 software developers and data experts.

Create a folder share?

pnp
Hi all,
How can I make a folder shared from a pc through C# code?
Thanks in advance,
Peter
Nov 16 '05 #1
4 6478
Use Platform Invocation to call NetShareAdd:

http://www.pinvoke.net/default.aspx/...32.NetShareAdd

--
Michael Giagnocavo
MVP
www.atrevido.net
"pnp" <pnp.@.softlab.ntua.gr> wrote in message
news:e0**************@TK2MSFTNGP11.phx.gbl...
Hi all,
How can I make a folder shared from a pc through C# code?
Thanks in advance,
Peter

Nov 16 '05 #2
Easy, Using System.Management classes....
using System.Management;
....

using (ManagementClass o = new ManagementClass("\\\\.\\root\\cimv2",
"Win32_Share", null))
{
string method = "create";
ManagementBaseObject inputArgs = o.GetMethodParameters(method);
inputArgs["Name"] = "SharedTemp"; // share as
inputArgs["Path"] = "c:\\temp"; // directory to share
inputArgs["Description"] = "this is public share";
inputArgs["Type"] = 0; // 0 = Disk share type
ManagementBaseObject outParams = o.InvokeMethod(method, inputArgs, null);
uint ret = (uint)(outParams.Properties["ReturnValue"].Value);
if(ret != 0)
Console.WriteLine("Failed {0}", ret);
}

Willy.

"pnp" <pnp.@.softlab.ntua.gr> wrote in message
news:e0**************@TK2MSFTNGP11.phx.gbl...
Hi all,
How can I make a folder shared from a pc through C# code?
Thanks in advance,
Peter

Nov 16 '05 #3
pnp
Thanks guys!
Nov 16 '05 #4
I have seen the way used by Willy quite often.
For those who don't understand what it is going about, check:
http://www.c-sharpcorner.com/Code/20...t/WMIPart1.asp
http://www.c-sharpcorner.com/Code/20...t/WMIPart2.asp
I reading it right now and I hope it will help me to understand WMI.
Nov 16 '05 #5

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

Similar topics

4
by: Dave | last post by:
I have an application where I am providing the user the ability to select or create a folder on a domain, using SHBrowseForFolder. When the user selects/creates a folder on a remote computer, it...
3
by: pnp | last post by:
Hi all, How can I remove a specific folder share from a folder, through C# code? Thanks in advance, pnp
2
by: freenews.netfront.net | last post by:
Hi, I am writing an asp.net / Active Directory application using vb.net in it's code-behind pages. The app is running on the W2k3 (r1) domain controller (e.g. server1). Does anyone know how...
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...
2
by: Joey | last post by:
Hey, I need to create a share on a remote folder using VB.NET, On the remote server, there is NO WMI, hence I need to find a way to do so, Without using WMI. Thanks ahead, --Joey
5
by: Bruce Parker | last post by:
I need to create a share on a folder on a local machine. How do you do this in VB.NET?
3
by: Nijazi Halimaji | last post by:
Hi How can I create a share of a folder with .net? Thanks alot! Nijazi Halimaji
3
by: Brian Hampson | last post by:
I've swiped the following code pretty much directly from a technet article, and modified it for my purposes. Something isn't working. I'm trying to 1) create a share on a remote server...
0
by: mrinalaryan | last post by:
create folder & upload file in the web server through web service-C# -------------------------------------------------------------------------------- im using web service to connect windows form...
2
by: Noorain | last post by:
sir how to create folder to use php script? i know how to file upload in folder to use php. but i can't how to create folder. i type name & its create my folder. Example: Type: test. my...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.