scubieman scubieman - 1 year ago 122
ASP.NET (C#) Question

Find Network location using drive letter

I am trying to upload file locations to my ASP .Net project. This would be so we can track location of all files used for a project. We also like a Hyperlink for each location so we can click and bring up the document.

When I use

<input type="file" id="myFile" name="myFile" />
I get drive letter with location. The issue is with using the drive letter in a Hyperlink it will not pull up the directory.

So I need the true location. So instead of H:/ I need \\Network.


HttpPostedFile file = Request.Files["myFile"];
string pathToFiles = Server.MapPath(file.FileName);

File name is Z:/ENG/AutoCAD 2000 stuff/acad.mnr

And error is

'Z:/ENG/AutoCAD 2000 stuff/acad.mnr' is a physical path, but a virtual path was expected.

Answer Source

Only if you used Server.MapPath(...) would you be able to do this, however this is dependent on the server having that location mapped.

Your best solution would be to use the fully qualified name \\server\share\file if you're working on a domain \ LAN based site.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download