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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show files of a mapped drive in an ASP

Status
Not open for further replies.

EddieVenus

Technical User
Apr 8, 2002
176
0
0
US
I want to display all of the word .doc files in a given directory, that happens to reside on a mapped drive. I have tried a few code examples I have found here, but they all are too weak. I need to be able to list the files, allow them to be accessed, all on a mapped drive, and only certian file types. The mapped drive happens to be common to everyone who will be using this page, but more importantly it is not local to the server. It is drive M: and for some reason I can map to c: and other local drives with some scripts, but not to M:. I would like to make the files show up with little pictures next to the file names, but this is not important at all. Really all I want is for this to work with a mapped drive so I can display the contents of a folder, or folders, and just pull out the .doc files, then allow people to view these files as if they were doing it from withing Windows Explorer.

Thank you.

--

EV
 
You can only do this if the drive is mapped on the server. This code should do what you need...
Code:
<%
strFolder = &quot;M:\temp&quot; 'change this to the folder you want
Set objFSO = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set objFolder = objFSO.GetFolder(strFolder)

For Each strFile In objFolder.Files
  If InStr(strFile.Name,&quot;.doc&quot;) Then
    Response.Write strFile.Name & &quot;<BR>&quot; & vbcrlf
  End If
Next

Set objFolder = Nothing
Set objFSO = Nothing
%>
Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
Good this is what I had come to as well as my final code, but it still does not work with the mapped drive. This code is great, the problem comes when I try to use the m:\ drive at all. It tells me &quot;Path not found&quot;, no matter how I state the drive. I tried to set it up in IIS too, as a virtual drive and IIS 5 would not allow me to add mapped drives a vdrived, and when I entered the path by hand, it tells me that there is an error. IIS can see the contents of the drive, but will not properly map to it. If I try the physical path it is the same thing, I can see the drive in Windows Exlorer, but I cannot get ASP and FSO to see it. What gives?
 
I believe this has to do with permissions. IIS uses annonymous authentication by default so ASP pages won't be able to see any drives on another server.
Perhaps you could set the username that IIS uses from the default to a real NT username that has permissions to view mapped drives. Then you should be able to view a shared folder on the other server using the \\server\c:\path or a drive letter if you have that drive and folder mapped to a specific drive letter all of the time.

Either way, please let us know if you get this working.

 
iminore & bernlaw

Sorry to take so long. I forgot about this project after it pushed to the back burner. I have not resolved it as of yet. I have not tried bernlaw's suggestion yet either. I will though.

Although it may not work, as you are only allowed 1 user to access a resource on server from your location. I.e I cannot log into the shared drive as 2 different users from one machine.

Perhaps this is the answer though. Maybe if I set the IIS user to my user account, or that of a user on the IIS server PC. Then it might access the drive properly. bernlaw you may have struck on something here, thank you. I will try this soon. I may forget again if something important comes up again as it generally does, but in any case I have a new idea now.

Thankyou

Eddie Venus
 
FYI -- I reassigned this project to a new guy who did it in javascript I think. I am not sure how he did it, but it worked. Then we changed the whole thing around and now we don't even use that anymore, go figure.

But I think that my last post was on to something, and if I would have tried again, using that information, it might have worked. I think that the issue was user related, and so that solution mentioned above should alleviate that issue.

EV3000
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top