none
map new drive to sharepoint sever shared folder using VisualWebpart with C#.net

    Question

  • Hi ,

    problem is does not show the Map drive name after mapping.

    here

    is my code:

    networks.LocalDrive = ddlDrive.SelectedItem.ToString();

    networks.ShareName =

    "\\\\servername\\foldername\\Shared%20Documents";

    networks.MapDrive(); below methond is mapdrive in visualwebpart.

       private void zMapDrive(string psUsername, string psPassword)
            {
                //create struct data
                structNetResource stNetRes = new structNetResource();
                stNetRes.iScope = 2;
                stNetRes.iType = RESOURCETYPE_DISK;
                stNetRes.iDisplayType = 3;
                stNetRes.iUsage = 1;
                stNetRes.sRemoteName = ls_ShareName;
                stNetRes.sLocalName = ls_Drive;
                //prepare params
                int iFlags = 0;
                if (lf_SaveCredentials) { iFlags += CONNECT_CMD_SAVECRED; }
                if (lf_Persistent) { iFlags += CONNECT_UPDATE_PROFILE; }
                if (ls_PromptForCredentials) { iFlags += CONNECT_INTERACTIVE + CONNECT_PROMPT; }
                if (psUsername == "") { psUsername = null; }
                if (psPassword == "") { psPassword = null; }
                //if force, unmap ready for new connection
                if (lf_Force) { try { zUnMapDrive(true); } catch { } }
                //call and return
                int i = WNetAddConnection2A(ref stNetRes, psPassword, psUsername, iFlags);
                if (i > 0) { throw new System.ComponentModel.Win32Exception(i); }
            }
    When I try to map to local  "\\mycomputer\shared" that no issue. But When I try to map to sharepoint server that there is issues. my application is using VisualWebpart with C#.net and running in sharepoint site and using Window 7 and Sharepoint 2010 pls help. thanks a lot.

    Monday, July 22, 2013 3:25 AM

Answers

  • Hi WilliamLin,

    perhaps you may check if you try to put the map drive string to the IE, may it be accessible or not?

    from the result did you see any permission denied issue or some network issue?

    to try, you may try to create a dummy folder or map folder then add the permission for the user name that you use.

    if it result as i should, then i suppose you need to add the access permission.

    http://support.microsoft.com/kb/297694/en-us


    Regards,
    Aries
    Microsoft Online Community Support


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.


    Wednesday, July 24, 2013 9:22 AM

All replies

  • Hello,

    Thank you for your question.

    We are trying to involve someone familiar with this topic to further look at this issue.

    This may take some time. Thanks for your patience.

    Thanks,


    Jack Gao
    TechNet Community Support

    Wednesday, July 24, 2013 7:47 AM
    Moderator
  • Hi WilliamLin,

    perhaps you may check if you try to put the map drive string to the IE, may it be accessible or not?

    from the result did you see any permission denied issue or some network issue?

    to try, you may try to create a dummy folder or map folder then add the permission for the user name that you use.

    if it result as i should, then i suppose you need to add the access permission.

    http://support.microsoft.com/kb/297694/en-us


    Regards,
    Aries
    Microsoft Online Community Support


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.


    Wednesday, July 24, 2013 9:22 AM