Avatar of synergiq
synergiqFlag for United Kingdom of Great Britain and Northern Ireland asked on

ASP ADODB.Stream LoadFromFile function does not work with network path ?

Hello there,

I am trying to stream a word document stored on a remote server in ASP but "The file could not be loaded" when the code below is executed.

However, if a use a physical path to a file stored on the webserver (C:\docs\ for instance), it will work just fine (of course the same .doc file was put in both folders).

Is there any workaround for this problem ? I bet I am not the first one that tried to do that.

Thanks in advance for input on that
'constant from another file put there
'network path of the folder for the doc file
CONST_DOCPATH = "\\mimas\boss\"
'if i put CONST_DOCPATH = "C:\docs\" it will work just fine
dim strFile 
strFile = "1_1_1.doc"
'strFile = "testSETUP.doc"
'response.Write strPath & strFile
'Set the content type to the specific type that you are sending.
Response.Buffer = True
Response.ContentType = "application/msword"
Set objStream = Server.CreateObject("ADODB.Stream")
            objStream.Type = 1
            objStream.LoadFromFile strPath & strFile
            Response.BinaryWrite objStream.Read
Set objStream = Nothing

Open in new window


Avatar of undefined
Last Comment

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Create a share on the fly with username/password, access the file through the share and disconnect the share.

sShareLetter = "Q"
Set oNetwork = Server.CreateObject("WScript.Network")
oNetwork.MapNetworkDrive sShareLetter, "\\mimas\boss\", False, "username", "password"
' get your file through sShareLetter & "\" & filename (you have that code)
Set oNetwork = Nothing

Open in new window


Right, IUSR_SERVENAME was a good start.

In fact, the website folder in IIS did not have any anonymous access account set. After setting it to the IUSR_SERVENAME, it works all fine.

Thanks for the help even if it was a webserver issue rather than a file server permission issue.

glad you figured
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes