Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3691790
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:11:15+00:00 2026-05-19T04:11:15+00:00

My program needs to read and write to folders on other machines that might

  • 0

My program needs to read and write to folders on other machines that might be in another domain. So I used the System.Runtime.InteropServices to add shared folders. This worked fine when it was hard coded in the main menu of my windows service. But since then something went wrong and I don’t know if it is a coding error or configuration error.

  • What is the scope of a shared folder? If a thread in my program adds a shared folder, can the entire local machine see it?
  • Is there a way to view what shared folders has been added? Or is there a way to see when a folder is added?

    [DllImport("NetApi32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
    internal static extern System.UInt32 NetUseAdd(string UncServerName, int Level, ref USE_INFO_2 Buf, out uint ParmError);
    
    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
    internal struct USE_INFO_2
    {
        internal LPWSTR ui2_local;
        internal LPWSTR ui2_remote;
        internal LPWSTR ui2_password;
        internal DWORD ui2_status;
        internal DWORD ui2_asg_type;
        internal DWORD ui2_refcount;
        internal DWORD ui2_usecount;
        internal LPWSTR ui2_username;
        internal LPWSTR ui2_domainname;
    }
    
    private void AddSharedFolder(string name, string domain, string username, string password)
    {
        if (name == null || domain == null || username == null || password == null)
            return;
    
        USE_INFO_2 useInfo = new USE_INFO_2();
        useInfo.ui2_remote = name;
        useInfo.ui2_password = password;
        useInfo.ui2_asg_type = 0;    //disk drive
        useInfo.ui2_usecount = 1;
        useInfo.ui2_username = username;
        useInfo.ui2_domainname = domain;
        uint paramErrorIndex;
        uint returnCode = NetUseAdd(String.Empty, 2, ref useInfo, out paramErrorIndex);
        if (returnCode != 0)
        {
            throw new Win32Exception((int)returnCode);
        }
    }
    
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T04:11:15+00:00Added an answer on May 19, 2026 at 4:11 am

    Each thread in a computer runs under a specific user account. Shared folder have security settings, i.e. they are subject to ACL-based access control, so that some users may have access permission and others may not. This means that the thread in your program may be able to “see” some shared folders, while other threads in the same computer (including the interactive user using the desktop) might be unable to “see” those folders.

    In summary: you should assume very little.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As the title says, I need to write a small program to read data
I have a program that needs to run as a separate NT user to
I have a program that needs to run as a normal user most of
I'm trying to write a program in Scala, that will accept SOAP-requests, get the
I have a process that continuously needs to write information. Furthermore, there is a
I need to clear the read-only flag of a file in my Perl program
The program needs to take in a simple string from the user and display
I have a bunch of PDF files and my Perl program needs to do
I am working on a small application in VB.NET. The program needs administrator privilege
Alright, quick question. A server is running in Eastern Time. PHP program needs to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.