hi,
I am doing a project where I have to create a shared
folder in a
remote machine in my network and then set the security
permissions to
it. I have created a shared folder in my own m/c but I
cannot create it
on another m/c.I am doing my project in C#.Any one can
please give me
the solution for the above problem,(preferably in C# code).I
am
attaching my code below which I used to create a shared
folder in my
own Machine.
using System.Management;
using System.DirectoryServices;
using System.IO;
try
{
// create a directory
Directory.CreateDirectory( "C:\newone");
// Create a ManagementClass object
ManagementClass managementClass = new ManagementClass
Win32_Share");
// Create ManagementBaseObjects for in and out parameters
ManagementBaseObject inParams =
managementClass.GetMethodParameters("Create");
ManagementBaseObject outParams; // Set the input parameters
inParams["Description"] = "new
file";
inParams["Name"] = "newone$";
inParams["Path"] = "C:\newone";
inParams["Type"] = 0x0; // Disk Drive
// Invoke the method on the ManagementClass object
outParams =
managementClass.InvokeMethod("Create", inParams,
null);
// Check to see if the method invocation was successful
if((uint)(outParams.Properties["ReturnValue"].Va
lue) != 0)
{
Response.Write ("Unable to share directory.");
}
else
{
Response.Write("Folder has been shared");
}
}
catch(Exception ex)
{
return ;
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "C# Developers" group.
To post to this group, send email to CSDevelopers googlegroups.com
To unsubscribe from this group, send email to
CSDevelopers-unsubscribe googlegroups.com
For more options, visit this group at http://gr
oups.google.com/group/CSDevelopers
-~----------~----~----~----~------~----~------~--~---
|