Hi all, I've got an 'include' file that is referenced in a .asp file. The include file (users.inc) needs read a .txt file (data.txt) located on another server (within the same domain). At this point, I'm not able to read that file from within the users.inc file in order to take action within the .asp file. Here's what I've got in the users.inc file: Const Filename = "/someDir/data.txt" Const ForReading = 1, ForWriting = 2, ForAppending = 3 Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0 '* Create a filesystem object Dim FSO set FSO = server.createObject("Scripting.FileSystemObject") '* Map the logical path to the physical system path Dim Filepath Filepath = Server.MapPath(Filename) if FSO.FileExists(Filepath) Then '* Get a handle to the file Dim file, Line set file = FSO.GetFile(Filepath) '* Open the file Dim TextStream Set TextStream = file.OpenAsTextStream(ForReading, TristateUseDefault) '* Read the file line by line Do While Not TextStream.AtEndOfStream 'do some stuff here Loop Set TextStream = nothing Else Response.Write("File not found.") End If Code (markup): Right now, I'm getting no error, if worked it around to manage to get the 'File not found.' message on the Else. The server with the .asp file which is the main page, as well as the users.inc file have a virtual directory set up over to the other server where the data.txt file is. In IIS manager, I can see the data.txt file from the other server. However, the web page can't. Any ideas? Oh yeah, and the vir dir has the build in IUSR_Webuser permissions on it. Thanks! P.S. if the data.txt file is place on the same server, this works just fine, but for reasons beyond my control, the data.txt file needs to be on that other server. P.P.S. I've given the IUSR_Webuser@ourdomain.com full authority on the associated files and folders on both the servers, but the file still can not be found by the asp page/.inc file. i've reduced the code, to just check for the file (from below) if FSO.FileExists(Filepath) Then Response.Write("File NOT found.") Else Response.Write("File not found.") End If Code (markup): the result is: File NOT found
In that last piece of code, you're basically indicating that the file was found, since it passed "true" when checking to see if it exists. If this is the case, then what is the problem? Are you saying that it recognizes that the file is there, yet it does nothing when trying to open it?
thanks for the reply whiteshark. that code can not find the file. all files and folders involved have full permissions under the same domain ID, doing this Response.Write "Absolute path: " & FilePath & "<HR>" Code (markup): indidates that the server is trying to find that file in the same directory as the asp script is. So not only is the directory wrong, but the server is wrong. Even though I've set up a virtual directory over to the data.txt file server will the same permissions, etc. If I'm on the server that's go the asp and inc files, looking in IIS manager, I can see the virtualy dir and the data.txt file there. any other ideas?
does a virtual directory need to be set up on the other (data.txt) server as well? In other words, a virt dir on both, the asp server's pointing to the data.txt file on the other server, and that server's vir dir pointing to the asp server?
If "someDir" is the name of the virtual directory, then that would be why because when you Server.MapPath("/someDir/data.txt") it gives you someDir under your web applications folder NOT whatever the VIRTUAL directory "someDir" points to. Instead of passing it "/someDir/data.txt" I think you need to pass it "..\someDir\data.txt" if the physical path is "c:\Inetpub\someDir" or whatever... you know make it relative to the main website root folder without using the virtual directory reference
Create a share on the remote server with the appropriate permissions Add anonymous account on the remote server using the same userid and password as the web server (IUSR_<servername>). - Reference Microsoft article ID: 184566 Add the local account to the guest group on the remote server Add the guest group to the shared folder access list Back on the web server on the site, uncheck the allow anonymous account to control the password option on the web site - Reference Microsoft article ID: 197964