Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Browse a directory on another server

Status
Not open for further replies.

jon24422531

Technical User
Jan 27, 2004
295
GB
I am struggling to understand why this does not work and I would appreciate some help.

On our Intranet I want to be able to list Word (.doc) and PDF files from a particular folder and enable the user to click the relevant entry and open the file.
Code:
<%
Dim objFSO, objFile, objFolder

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'Set objFolder = objFSO.GetFolder("D:\")
Set objFolder = objFSO.GetFolder("\\Server26\BusinessData\")

For Each objFile in objFolder.Files
Response.Write objFile.Name & "<br>"
Next
Set objFolder = Nothing
Set objFSO = Nothing
%>
It works with the D: (commented out) but that is all, and it does not work at all with a different server (\\Server26\BusinessData\)

I have tried every combination of backslash and forwardslash that I can think of. We even have it mapped (as an S: Drive) and that doesn't work either. All I get is Path Not Found.

I have also tried it with Server.MapPath
Code:
Set objFolder = objFSO.GetFolder(Server.MapPath("//Server26/BusinessData"))
And the error is:
An invalid '/' or '\' was found in the Path parameter for the MapPath method.

Getting very confused.....

Jonathan
 
objFSO.GetFolder is expecting a full path eg "d:\" or "e:\inetpub\
The MapPath method maps a relative or virtual path to a physical path.
If the path starts with a forward or backward slash, the method returns the path as if the path is a full virtual path.
If the path does not start with a slash, then the method returns the path relative to the directory of the ASP file being processed.


With mappath you are able to "translate" a virtual directoy on the webserver into a physical path.

I suggest you make a small test script with different variations an stydy the results. eg:
Code:
response.write server.mappath("\BusinessData") & "<br>"
response.write server.mappath("BusinessData") & "<br>"
response.write server.mappath("\") & "<br>"
'etc
 
Hi Foxbox

Apologies for the late response, this particular project has been overtaken by another until now.

So, I can get the search to work on the local server, but to list files on the domain I need to use IUSR_computername and allow this access to the server with the files on it. However this then means that our users cannot use Windows Authentication to access all the other SQL data that is pertinent to their UserID etc.

I can get the logged on user with this:
Code:
Dim objNTInfo
Set objNTInfo = CreateObject("WinNTSystemInfo")
GetUserName = objNTInfo.UserName


Is it possible to run the Scripting.FileSystemObject with Windows Authentication? If so, how?

Jonathan

 

'This is the code for an unbound list box called "FileList" and the code goes in the row source. After you highlight the record you click the button and it pulls the record hope this helps.

SELECT DISTINCTROW Scan.FileName, Scan.FileDate, Scan.FilePath
FROM Scan WHERE (((Scan.FileID)=[forms]![YourProjects]![YourProjectID]))
ORDER BY Scan.FileDate DESC;

'On Click of a form button
Private Sub FileList_Click()
Dim path As String
Dim file As String

'Me.FileImage.Picture = Me.FileList.Column(2)
Me.FileImage.HyperlinkAddress = Me.FileList.Column(2)

End Sub
 
Oh Colum2 in the scan table is where the direct path to your folder files are stored.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top