473,480 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

LoadFromFile using a mapped network drive

15 New Member
Hello everyone

I'm creating an ASP classic application that let's users download and save PDF files without having to bring them up in the browser. I have successfully used the LoadFromFile method to perform this feat but not in the manner in which I ultimately want things to be.

Currently the PDF's sit on the server itself, but I would like for these to be on a different computer. When I try to set up this scenario, the LoadFromFile method can never find the file.

My first thought was to Map a network drive to the location of the PDF's on the other computer. Still, LoadFromFile can't find the files.

Is there any way to use LoadFromFile on the server, but have the file I'm looking for reside on a diffrent computer on the same network?
Here is my logic....

Where I set the CompletePath variable, "S:" is the mapped network drive.

Expand|Select|Wrap|Line Numbers
  1. If Len(Trim(Session("MEMBER_ID"))) > 0 Then
  2.     Response.Clear
  3.     Response.contentType = "application/octet-stream"
  4.     Response.addheader "content-disposition", "attachment; filename=" & FileName
  5.  
  6.     Set Stream = server.CreateObject("ADODB.Stream")
  7.  
  8.     Stream.Type = adTypeBinary
  9.     Stream.Open
  10.  
  11.     CompletePath = "S:\Inetpub\wwwroot\PDF\" & GroupName & "\" & FileName
  12.  
  13.     Stream.LoadFromFile CompletePath 
  14.     While Not Stream.EOS
  15.         Response.BinaryWrite Stream.Read(1024 * 64)
  16.     Wend
  17.  
  18.     Stream.Close
  19.     Set Stream = Nothing
  20.  
  21.     'Response.write("<html>")
  22.     'Response.write(CompletePath)
  23.     'Response.write("</html>")
  24.  
  25.     Response.Flush
  26.     Response.End
  27. End If
  28.  
Thanks a million!!!!!! Any help would be wonderful. :)
Apr 5 '08 #1
6 5835
danp129
323 Recognized Expert Contributor
Try loading the full UNC path "\\servername\sharename\subfolder\filename.ext " and make sure the file has read rights given to the "IUSR_wwwserver" user account.
Apr 7 '08 #2
cryogeneric
15 New Member
Hi danp129, Thanks so much for the response.

The web server will vpn to a computer behind the firewall that contains the files. So by "servername", I'm assuming IP address will be fine.

In other words: \\100.100.100.1\pdf\somefile.pdf

Theoretically, I don't see any reason why this shouldn't work. The path shouldn't matter if the server can read from the folder (which it can). But it doesn't work. :(

The PDF folder is currently shared, AND I turned on "web sharing".
Apr 9 '08 #3
cryogeneric
15 New Member
Solved!

While for whatever reason I'm unable to run LoadFromFile and read from a folder on a different computer, I was able to solve the problem by placing the script that calls the LoadFromFile method on the Network computer and calling THE SCRIPT using the IP address.

I guess LoadFromFile is unable to read from a folder that is not physically on the computer that the script is called from. Seems weird, but trust me, I spent hours trying to get it to work.
Apr 9 '08 #4
DrBunchman
979 Recognized Expert Contributor
That's interesting. The FileSystem object has a similar drawback where the Exists property always returns false if you use it on a file stored on a different machine. This is a good solution though to call a script running on the remote server.

Glad you got it sorted.

Dr B
Apr 10 '08 #5
cryogeneric
15 New Member
Thanks.

That's good to know about the FileExists method. I suspect this solution could be used to get around that problem as well. Of course, IIS needs to be setup on the remote server.

In fact, now that I think about... I wonder if you could "include" a script on the remote server which has subs that call FileExists or LoadFromFile... hmmm

I might have to test that someday. :)
Apr 10 '08 #6
danp129
323 Recognized Expert Contributor
I think the problem with mapped drives is that mapped drives are user specific and IUSR_ doesn't have any mapped drives.
Apr 11 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

14
8677
by: Curtis Tammany | last post by:
Hello- Can someone tell me if DSOFile.dll can be accessed within ASP.NET? DSOFile.dll is registered and I have no problem using it in my .ASP scripts. I have tried the following: Dim...
1
971
by: PeterNZ | last post by:
Hi all, I developped an C# app which is using FileSystemWatcher. If a file is created in a specific folder, it opens the file and does some processing. This functionality works without...
5
21531
by: Niloday | last post by:
Hi All, I am trying to access a mapped network drive from a service that I have created. The service needs to create/delete folders/files on a network drive. When I tried to connect to a...
5
4444
by: Nirosh | last post by:
Hi All, Can any one suggest me a best way to do this .. I have a thrid party tool "EXE" that we need to use with our web service to manipulate some complex XML files, which reside in a...
2
4723
by: createdbyx | last post by:
I am trying to make a file sync utillity to sync files between my laptop and my desktop pc. On my desktop machine (xp pro sp2) I have shared my "Visual Studio Projects" folder using windows simple...
4
11720
by: sajid_yusuf | last post by:
Hi I am trying to develop a Windows service in VB.NET which has timer enabled and keeps checking a folder (or group of folders) for any new file or changed files. As soon as it detects any new...
1
2545
by: dkultasev | last post by:
Hello, I developed the program for multi use. The program reads data from the text file and puts modified data back to another file. This program was uploaded to mapped network drive. When I try...
24
3649
by: =?Utf-8?B?QnJpYW4gTmljaG9sc29u?= | last post by:
Hello, I'm trying to create an admin page that can run miscellaneous scripts for our IT department. Currently, I'm trying to create a script that can map a network drive for a user (e.g. a form...
2
3508
by: =?Utf-8?B?SGF6ZWxyYWg=?= | last post by:
I posted this question on a different website but I didn't get a response that worked. If I run this code from my computers hard drive, C:\, it detects the networked mapped drive, J:\, just...
0
7055
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6920
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7059
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6758
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7010
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5362
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3003
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
203
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.