|
-
Oct 2nd, 2007, 11:46 AM
#1
Thread Starter
Fanatic Member
filesystem object Q
I am pulling this text (\\3.72.35.122\Shared\Testdoc.doc) from a DB and want to test if it is actually a good link. The below code does not seem to see the link nor the file. The link="\\33.2.35.122\Shared\Testdoc.doc"
<code>
<%
dim fs
set fs=Server.CreateObject("Scripting.FileSystemObject")
if fs.FileExists(objrst("link"))=true then
%>
<a href="<%=objrst("link")%>"><img src="images/<%=objrst("image")%>"></a>
<%else %>
<img src="images/disconn.ico">
<%
end if
set fs=nothing
%>
</code>
How come it does not see it?
-
Oct 2nd, 2007, 12:00 PM
#2
PowerPoster
Re: filesystem object Q
Probably cause its not part of the local File System, if it was a mapped drive then it might work.
-
Oct 2nd, 2007, 12:20 PM
#3
Thread Starter
Fanatic Member
Re: filesystem object Q
 Originally Posted by rory
Probably cause its not part of the local File System, if it was a mapped drive then it might work.
But I can open the file in a <a href...>.
Even mapped drives such as: "s:\foldername\testdoc.doc" open correctly. but the FSO isn't even finding docs mapped to the same drive letter.
My goal is to test the mapped drives from "E" to "Z" drive for the folder/document and connecting that way.
Say the file is on a shared (communal) mapped drive mapped as "S" on my machine, but on the server its mapped as "M". I want to locate and open the file.
I figured if I did a fileexists=false then move to the first letter and move itll is found.
Last edited by juliemac; Oct 2nd, 2007 at 12:35 PM.
-
Oct 2nd, 2007, 02:04 PM
#4
Re: filesystem object Q
Are you sure the objrst("link") is returning a valid path? Have you tried hard coding the fs.FileExists with a valid path to see if it responds the way you expect it to?
-
Oct 2nd, 2007, 03:12 PM
#5
Thread Starter
Fanatic Member
Re: filesystem object Q
 Originally Posted by MarkT
Are you sure the objrst("link") is returning a valid path? Have you tried hard coding the fs.FileExists with a valid path to see if it responds the way you expect it to?
when the link is used in a <a href> tag they work.
What I am trying to do, is match folder/doc to mapped drives. If the file is on the "S" drive on my machine, and I move to another machine where the same folder/doc is mapped to the "F" drive, modify the link appropriately.
Sounds easy, but its driven me nuts today...
-
Oct 2nd, 2007, 06:26 PM
#6
PowerPoster
Re: filesystem object Q
Is this in an ASP page, or a Stand Alone Script?
-
Oct 2nd, 2007, 06:28 PM
#7
PowerPoster
Re: filesystem object Q
 Originally Posted by juliemac
when the link is used in a <a href> tag they work.
What I am trying to do, is match folder/doc to mapped drives. If the file is on the "S" drive on my machine, and I move to another machine where the same folder/doc is mapped to the "F" drive, modify the link appropriately.
Sounds easy, but its driven me nuts today...
yeah but that example above isnt showing a mapped drive, as there is no letter, just an IP? A Href will open the IP as thats like a web page, but FSO will not, has to be a Fixed Folder path.
EDIT - maybe possible ... see this post:
http://forums.devx.com/showthread.php?t=149199
Particularly this part:
The FSO uses DCOM for networked drives and will use impersonation for file permissions and run as whomever executed the script. Alternatively, you can set this to "run as" another set of credentials either in a Windows Scheduled Task, or in the DCOM config if you set this application up as a service or batch process.
And more on FSO and drives:
http://www.microsoft.com/technet/scr....mspx?mfr=true
Sorry I dont have any networked drives to test with.
Last edited by rory; Oct 2nd, 2007 at 06:33 PM.
-
Oct 2nd, 2007, 07:11 PM
#8
Thread Starter
Fanatic Member
Re: filesystem object Q
 Originally Posted by rory
Is this in an ASP page, or a Stand Alone Script?
Its an ASP page that provides links drawn from a database.
I got it working using a shared folder on my PC as well as networked drives.
But finding the letter of the drive from PC to PC?
I'll read up on the links provided. Thanks, but I may be back in the morning
-
Oct 2nd, 2007, 10:40 PM
#9
PowerPoster
Re: filesystem object Q
Accessing those other network drives might be an issue though, not sure but could be a permissions thing, to do with it being inside ASP. Though you said you got it to work so ... let us know what happens after checking out those links.
-
Oct 3rd, 2007, 07:09 AM
#10
Thread Starter
Fanatic Member
Re: filesystem object Q
Ok. I wrote this last night.
<code>
shortpath=right(objrst("link"),(len(objrst("link"))-1))
for i=0 to ubound(Xdrive)
newpath= Xdrive(i) & shortpath & "<br>"
Response.Write newpath & "<br>"
if objFSO.FileExists(newpath)=true then
filepath=newpath
Response.Write newpath & " true<br>"
Response.end
exit for
Response.Write newpath & " False<br>"
end if
next
</code>
Even though the link will open the doc in an <A href> tag and I can enumerate the drives on the system to create an array of attached drive letters, testing for the doc fails. Man, this one has me stumped....
Last edited by juliemac; Oct 3rd, 2007 at 07:14 AM.
-
Oct 3rd, 2007, 08:05 AM
#11
Thread Starter
Fanatic Member
Re: filesystem object Q
Ok. It seems I am returning the servers mapped drives not the clients. <ugh> I have the same drives mapped on the server as well but cant seem to draw anything down.
But the mapped drives are not returning a true when testing fileexists with the FSO.
Windows explorer opens the drive and views files. Why isnt FSO responding to the files I query based on the clients system?
Last edited by juliemac; Oct 3rd, 2007 at 09:05 AM.
-
Oct 3rd, 2007, 06:14 PM
#12
PowerPoster
Re: filesystem object Q
Dont have any Networked drives here to test with .. sorry
-
Oct 3rd, 2007, 06:16 PM
#13
Re: filesystem object Q
 Originally Posted by juliemac
Ok. It seems I am returning the servers mapped drives not the clients. <ugh>
That makes sense. ASP runs on the server. Imagine what kind of damage a website could do to your pc if it could run FSO commands on your machine.
-
Oct 3rd, 2007, 06:58 PM
#14
PowerPoster
Re: filesystem object Q
 Originally Posted by MarkT
That makes sense. ASP runs on the server. Imagine what kind of damage a website could do to your pc if it could run FSO commands on your machine.
I think she means client machines connected to the server .. as in mapped drives?
-
Oct 3rd, 2007, 07:38 PM
#15
Thread Starter
Fanatic Member
Re: filesystem object Q
MarkT has a point. If I were so inclined I could do a lot of damage. But then my customers wouldn't like it 
I created a portal system that can identify and store docs for quick retrieval. Great from the persons computer, but what if when they move to another system?
My brain is fried and I need sleep. Thanks guys!
-
Oct 3rd, 2007, 11:49 PM
#16
PowerPoster
Re: filesystem object Q
Once its ASP then its Server side and working off the server, people just accessing it from outside the network wont be effected. If it was client side VBscript then thats a different story.
-
Oct 4th, 2007, 07:35 AM
#17
Thread Starter
Fanatic Member
Re: filesystem object Q
<sigh> Still working on this guys.
I am using a <input type=file> tag to get the file location.
The first char in the text is a letter. Is there a way to find the servername or the mapped folder name based on this letter? If I can find the root folder name I can "select case" the foldername and come up with the server name.
-
Oct 4th, 2007, 08:10 AM
#18
Junior Member
Re: filesystem object Q
 Originally Posted by juliemac
<sigh> Still working on this guys.
I am using a <input type=file> tag to get the file location.
The first char in the text is a letter. Is there a way to find the servername or the mapped folder name based on this letter? If I can find the root folder name I can "select case" the foldername and come up with the server name.
If you're using an <input type = file>, then you're fixing to upload a file to the server. Not probably a good idea ?
If you're trying to check for existence of a remote file, then the process your web server runs under must have permission to do that. As has been said.
-
Oct 4th, 2007, 05:08 PM
#19
Thread Starter
Fanatic Member
Re: filesystem object Q
The tag can be used to uload with additional code, but all I am doing is pulling the location of the file with in the network.
I created a table called drives. Filled one column with the known names of the shared drives andother column with the full server name.
The client has to open the explorer and find which drive they mapped too and the letter.
Using the <input type=file> tag, they located the file (which shows the drive letter) match the letter to the server name and create the full path.
Works, but its difficult for the end user. I need some thing better....
-
Oct 4th, 2007, 05:26 PM
#20
PowerPoster
Re: filesystem object Q
If you have control over this Server, maybe best, if you could, write a small VB6 DLL and then use that in your ASP page .. can do so much more and easier with VB .. 
Though, FSO should be able to do quite alot in itself.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|