ASP doesn't opens files

Status
Not open for further replies.

mad1231moody

Journeyman
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:\WINDOWS
But 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

-The BlacKCoaT Operative-
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.
 
OP
mad1231moody

mad1231moody

Journeyman
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

MMO Addict
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..
 

Rollercoaster

-The BlacKCoaT Operative-
try
Code:
<a href="
            <%
            string str = @"*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#
 
Last edited:

Rollercoaster

-The BlacKCoaT Operative-
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");
%>
 
Last edited:
OP
mad1231moody

mad1231moody

Journeyman
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
 
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 :

Code:
<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

-The BlacKCoaT Operative-
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
 
Last edited:
OP
mad1231moody

mad1231moody

Journeyman
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 :

Code:
<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:
 
OP
mad1231moody

mad1231moody

Journeyman
Its alright coaster, I thought that you might be knowing Javascript. Thanks for the tips. Hope crazy gets the idea soon
 
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 :

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 :-|
 
Status
Not open for further replies.
Top Bottom