0

I made a server and many users are accessing it.

Now I want to get Unc path for mapped drive for each user which will of course be different.

Actually I need the complete path in order to access those files in my c# code.

Taking complete path from user is not an option as they are not developers. What I want to do is ...If someone gives me Q: then I should get absolute path like this \\server1\foo. I have searched but unable to get solution for this.

Is there any way to do this?

In C#(backend) or in angularjs(frontend) ?

From this_link I have learned that I cannot get the complete path just by uploading it in using javascript because For security reasons browsers do not allow this.

can I provide more details on this question?

Amrit
  • 2,115
  • 1
  • 21
  • 41

1 Answers1

0

Use WMI to check for network path. You can use ManagementClass object in C#. We can get this information from Win32_LogicalDisk, you will be interested in Name and ProviderName properties.

select * from win32_LogicalDisk where driveType = 4

instance of Win32_LogicalDisk
{
    Access = 0;
    Caption = "Z:";
    Compressed = FALSE;
    CreationClassName = "Win32_LogicalDisk";
    Description = "Network Connection";
    DeviceID = "Z:";
    DriveType = 4;
    FileSystem = "NTFS";
    FreeSpace = "1805758038016";
    MaximumComponentLength = 255;
    MediaType = 0;
    Name = "Z:";
    ProviderName = "\\\\<server>\\<path>";
    Size = "2000396742656";
    SupportsDiskQuotas = FALSE;
    SupportsFileBasedCompression = TRUE;
    SystemCreationClassName = "Win32_ComputerSystem";
    SystemName = "<server>";
    VolumeName = "New Volume";
    VolumeSerialNumber = "<id>";
};

EDIT : We have to connect using \\<server>\root\cimv2 to fetch share information from remote machine. Thanks Alex for pointing that out.

Amit Shakya
  • 1,396
  • 12
  • 27
  • Thos code will not do anything useful when running on server (as drive napping is local machine specific) and can not be used with JavaScript... – Alexei Levenkov Nov 24 '17 at 07:36
  • But as per original question, he has option to run code in C#. I am going with that assumption. – Amit Shakya Nov 24 '17 at 08:47