Retrieving a file from a different machine to a ASP.NT web site

H

Hrvoje Vrbanc

Hello all,

I have already once posted something similar but somehow the results proved
inconclusive so I have to ask again :)
What paths should I use if I want to retrieve the files located on the file
system on another computer (not my web server)? I would like to get a list
of files within a directory and to display it on an ASP.NET page.

I have tried the use of this code:

Dim dirInfo As New DirectoryInfo(Server.MapPath(DirectoryPath))
DataGrid1.DataSource = dirInfo.GetFiles("*.*")

Of course, this works fine if I, for example, set the value of the variable
"DirectoryPath" to contain the path to a folder on my web server. But, what
to do if the targeted folder is situated on another computer within the same
domain (or, if it's a web share)?

I cannot use absolute path of the mapped shared folder (e.g. F:\Temp), I
cannot use UNC path (e.g. \\OtherMachine\Temp).....what should I do?

Thank you,
Hrvoje
 
H

Hrvoje Vrbanc

I'm sorry for the mistake in the code, of course it isn't:

Dim dirInfo As New DirectoryInfo(Server.MapPath(DirectoryPath))

but instead

Dim dirInfo As New DirectoryInfo(DirectoryPath)


Hrvoje
 
B

bruce barker

to access network resouces you need to impersonsate a valid domain account
which has permissions on the file share. the standard asp.net account can
not acess any unc files. the easiest way to do this is to specifiy the
account in web.config.

<identity impersonate="true" userName="domain\user" password="password" />

note: you will need to implement your own security


-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top