scubieman scubieman - 2 months ago 18
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 \fs1.company.local\Network.

Update:

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

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.