View Full Version : ASP doesn't opens files
mad1231moody
06-02-2008, 07:52 PM
Hi friends, got a query and need solution as soon as I can. You may be knowing that in HTML if we use this
<a href="file://C:\WINDOWS"> Open</a>When I click on open it opens WINDOWS folder in Explorer. But this is not the case in asp. Although when I bring the mouse on the link in ASP, I get the same path as I get in HTML,i.e
file:///C:\WINDOWSBut when I click it nothing happens.So please tell me a way on how do I open files and folders in asp.
Another query
<% @language=VBScript %>
<% Option Explicit %>
<% dim str
str="file://C:\WINDOWS"
%>
Now I want this string to be passed in an HTML file,and use it in
<a href="file://C:\WINDOWS"> in the html file. Please guide if this is possible. waiting for your response:eek:
Rollercoaster
06-02-2008, 10:03 PM
i tried what u said and it truly doesn't work. i found thru trial n error that it works for files under the website directory only. may be there is some property we need to specify or un-specify that is causing this.
mad1231moody
06-02-2008, 10:30 PM
Yes it does opens files .jpg, .txt . But it is unable to open folders in win explorer. Do you have an answer for my second query
amitava82
07-02-2008, 01:02 AM
can't you just echo out the 'str'?
IN PHP we do like this:
<a href="<?php echo $str; ?> ">Click me</a>
So, in asp echo out the str in a asp tag..
mad1231moody
07-02-2008, 05:11 PM
Well can u please make sure if echo can be used in asp. Cause I am not using php for this purpose
amitava82
08-02-2008, 12:13 AM
Try this:
<%=str%>
mad1231moody
09-02-2008, 09:01 AM
So you say I should try like this
<a href=<%=str%>>Click me</a>
amitava82
09-02-2008, 09:35 AM
<a href="<%=$str%>">Click me</a>
Why not you just try it rather than asking for confirmation!
mad1231moody
09-02-2008, 02:06 PM
Well mate it is not working :( . Please if any more tricks u can get please
Rollercoaster
11-02-2008, 02:53 PM
try
<a href="
<%
string str = @"http://www.thinkdigit.com";
Response.Write(str);
%>
">sometext</a>
works with web addresses but it will still not open any file with the file:///
note- code in c#
mad1231moody
11-02-2008, 06:34 PM
Well mate that is the real prob, I want the file:/// to open. http:/// works fine anyways
Rollercoaster
11-02-2008, 07:12 PM
if u can tell here what u want to build that may be i can give better alternatives.
you can also try to use a asp:HyperLink with this code in its click event
System.Diagnostics.Process.Start(@"c:\windows");
or open a pop up self closing window with
<%
System.Diagnostics.Process.Start(@"c:\windows");
%>
mad1231moody
12-02-2008, 12:39 AM
Mate I am preparing a search engine. As you know that the FolderExists and FileExists method of the FileSystemObject can be used to find out a file or folder exists on the server or not. In my case the server is localhost.
The Getfile method can then be used to find the attributes like Date last modified,Last accessed and Path. Now what I want to do is open the path that I get. I thought that using <a href=path> will be the best idea, but it is not so. @Rollercoaster the code you gave in above post, can u write a sample basic code and post it here. As I am not familiar with the code you have written. I hope I can get some help :p
Krazy_About_Technology
12-02-2008, 02:05 AM
if u can tell here what u want to build that may be i can give better alternatives.
you can also try to use a asp:HyperLink with this code in its click event
System.Diagnostics.Process.Start(@"c:\windows");
or open a pop up self closing window with
<%
System.Diagnostics.Process.Start(@"c:\windows");
%>
Dude he is not using ASP.NET, its vanilla ASP.
Now as for your problem, the code that writes the exact line in the browser is :
<a href=<% response.write(chr(34) & "file://c:/" & chr(34)) %>>Open C Drive</a>
But if you run it as an asp page it wont open the c drive even when the html code is correct. You can check this by using View Source and then copying and pasting the html code in a local html file.
The reason for this is when an asp page is served, it is first parsed using the asp parser isapi dll on iis. Then iis sends the resultant html to client. Now all the html when arrives on client is first stored in the temporary internet files folder (or the cache) and then it is displayed. That folder is a special system folder and is protected. You cant run any system commands from there an thats why the link is not working.
Although i am aware that there is a way to bypass this, i cant remember it now. I'll post back when i get it again. Ok.
Rollercoaster
12-02-2008, 11:39 AM
i was under the impression that we are talking abt asp.net...
i have zero idea abt asp. never ever used it. started directly with .net
the best way would be to ask some javascript guru to write u a page start executing code which does-
1. hyperlink to open a popup/invisible windows
2. open the file/folder from that window
3. popup window closes itself
mad1231moody
12-02-2008, 12:36 PM
Dude he is not using ASP.NET, its vanilla ASP.
Now as for your problem, the code that writes the exact line in the browser is :
<a href=<% response.write(chr(34) & "file://c:/" & chr(34)) %>>Open C Drive</a>
But if you run it as an asp page it wont open the c drive even when the html code is correct. You can check this by using View Source and then copying and pasting the html code in a local html file.
The reason for this is when an asp page is served, it is first parsed using the asp parser isapi dll on iis. Then iis sends the resultant html to client. Now all the html when arrives on client is first stored in the temporary internet files folder (or the cache) and then it is displayed. That folder is a special system folder and is protected. You cant run any system commands from there an thats why the link is not working.
Although i am aware that there is a way to bypass this, i cant remember it now. I'll post back when i get it again. Ok.
Thanks Crazy for the xplanation mate. Now I know that it is not possible to open folders. I hope u get the solution soon. Please mate m in hurry
i was under the impression that we are talking abt asp.net...
i have zero idea abt asp. never ever used it. started directly with .net
the best way would be to ask some javascript guru to write u a page start executing code which does-
1. hyperlink to open a popup/invisible windows
2. open the file/folder from that window
3. popup window closes itself
@Rollercoaster thanks for the ideas, but I have not got what u wanna say. SUre I have books for Javascript but can't make out much from them. Please I am a noob and would like you to post a sample code. Please I request again!!:sad:
Rollercoaster
12-02-2008, 02:29 PM
i donno javascript either. you should post on some javascript/asp forum instead of here.
try- forums.aspfree.com , www.webdeveloper.com/forum/forumdisplay.php?f=3 and search google for more
i tried giving tips as much as i could but i cant do ur work for u..
mad1231moody
12-02-2008, 02:38 PM
Its alright coaster, I thought that you might be knowing Javascript. Thanks for the tips. Hope crazy gets the idea soon
Krazy_About_Technology
13-02-2008, 01:54 AM
Yaar i dont think its gonna work. When working from ASP, you are an alien for the system. It wont allow any such thing. i even tried with this javascript based code :
<html>
<head><title>ASP Page</title></head>
<body>
<script language='javascript'>
function openwnd(pth)
{
window.open(pth);
}
</script>
<a href="#" onClick=<% response.write(chr(34) & "javascript:openwnd('file://c:/');" & chr(34)) %>>Open C Drive</a>
<body>
</html>
I think you are out of luck :-|
vBulletin® v3.7.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.