Network path is not shared when trying to create folder with sharing everyone using c#

krishna 466 Reputation points
2022-09-26T05:12:21.743+00:00

I have a wpf application in which i try to create folder on client machine and give sharing permission to everyone as i want to transfer crystal reports to those folders (unc network folder).I am able to create the folder with sharing permission showing as everyone with code but when i click the folder properties->sharing .It says network path not shared .

244671-1.png244681-2.png

I have impersonated an administrator account and created the folder using below code ,i got from a stackoverflow post

private static void GrantAccess(string file)  
{  
  
    bool exists = System.IO.Directory.Exists(file);  
    if (!exists)  
    {  
        DirectoryInfo di = System.IO.Directory.CreateDirectory(file);  
        Console.WriteLine("The Folder is created Sucessfully");  
    }  
    else  
    {  
        Console.WriteLine("The Folder already exists");  
    }  
    DirectoryInfo dInfo = new DirectoryInfo(file);  
    DirectorySecurity dSecurity = dInfo.GetAccessControl();  
    dSecurity.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.NoPropagateInherit, AccessControlType.Allow));  
      
    dInfo.SetAccessControl(dSecurity);  
  
}  
Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
4,739 questions
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,670 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 39,351 Reputation points
    2022-10-06T14:48:14.42+00:00

    Hello there,

    Make sure TCP/IP NetBIOS is enabled.

    Here's how to make sure TCP/IP NetBIOS is enabled:

    Go to Start.

    Go to Search, enter the word Services, and press Enter.

    Double-click TCP/IP NetBIOS Helper on the right pane, and make sure the Startup type property is set to Automatic.

    Go to Control Panel > Network and Internet > Network and Sharing Center, select Change adapter settings on the left pane, and then double-click Ethernet.

    Select Properties and double-click Internet Protocol Version 4 (TCP/IPv4) on the Networking tab.

    Select Advanced, select Enable NetBIOS over TCP/IP on the WINS tab, and then press Enter.

    Select OK twice to close the dialog box

    --------------------------------------------------------------------------------------------------------------------------------------------

    --If the reply is helpful, please Upvote and Accept it as an answer--

    0 comments No comments