Hi,
I am running straight ASP and not ASP.NET.
I have a page which lists a bunch of project numbers each with an href link
to an Excel file whose name is project number.xls on the server. I want to
check if the file exists, if it does enable the link else disable the link.

I have the following code.

<%
dim strProj
function findFile(strProj)
Dim objFSO, objFolder
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("../busops/prog")
For Each strProj in objFolder.Files
If strFile.Name = strNumber Then
findFile = strProj.Name
Else
findFile = null
End If
Next
Set objFolder = Nothing
Set objFSO = Nothing
end function

%>
<%
strProj = trim(oRsMOIE("ProjectNum"))
if findFile(strProj) = null then
%>
<td colspan="2" align=center><a href="#"><%=oRs("ProjectNum")%></a></td>
<%
else
%>
<td colspan="2" align=center><a href="<%="MIP/" &
trim(oRsMOIE("ProjectNum")) & ".xls"%>"><%=oRsMOIE("ProjectNum")%></a></td>
<%
end if
%>

I get an path not found error on the GetFolder line.

Any help would be greatly appreciated.

Is the fileExists only available for .NET? If so, how else I would check for
the file?
Is it because browse directory listing permission is not granted in IIS? If
so, how else I can check if the file exists? I am not allowed to grant browse
directory listing permission.

Thanks much.

RE: Verifying if file exists on href link by omsoft

omsoft
Thu Apr 24 15:44:00 CDT 2008



"omsoft" wrote:

> Hi,
> I am running straight ASP and not ASP.NET.
> I have a page which lists a bunch of project numbers each with an href link
> to an Excel file whose name is project number.xls on the server. I want to
> check if the file exists, if it does enable the link else disable the link.
>
> I have the following code.
>
> <%
> dim strProj
> function findFile(strProj)
> Dim objFSO, objFolder, strFile
> Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
> projPath = server.MapPath("../busops/MIP/")
> Set objFolder = objFSO.GetFolder(projPath)
> For Each strProj in objFolder.Files
> If strFile.Name = strProj & ".xls" Then
> findFile = strFile.Name
> Else
> findFile = null
> End If
> Next
> Set objFolder = Nothing
> Set objFSO = Nothing
> end function
>
> %>
> <%
> strProj = trim(oRs("ProjectNum"))
> if findFile(strProj) = null then
> %>
> <td colspan="2" align=center><a href="#"><%=oRs("ProjectNum")%></a></td>
> <%
> else
> %>
> <td colspan="2" align=center><a href="<%="MIP/" &
> trim(oRs("ProjectNum")) & ".xls"%>"><%=oRs("ProjectNum")%></a></td>
> <%
> end if
> %>
>
> I can not seem to disable the link when the file is not there.
>
> Any help would be greatly appreciated.
>
> Is the fileExists only available for .NET? If so, how else I would check for
> the file?
> Is it because browse directory listing permission is not granted in IIS? If
> so, how else I can check if the file exists? I am not allowed to grant browse
> directory listing permission.
>
> Thanks much.

Re: Verifying if file exists on href link by Michael

Michael
Thu Apr 24 19:01:36 CDT 2008

> ...
>
> I get an path not found error on the GetFolder line.
>
> Any help would be greatly appreciated.

Try this:

...
Set objFolder = objFSO.GetFolder(Server.MapPath("../busops/prog"))
...

--
Michael Harris



Re: Verifying if file exists on href link by omsoft

omsoft
Fri Apr 25 06:16:01 CDT 2008

Thanks Mike, I fixed that one. But it does not check for the file exists. I
think I need to use FileExists, but am not sure of the implementation.



"Michael Harris" wrote:

> > ...
> >
> > I get an path not found error on the GetFolder line.
> >
> > Any help would be greatly appreciated.
>
> Try this:
>
> ....
> Set objFolder = objFSO.GetFolder(Server.MapPath("../busops/prog"))
> ....
>
> --
> Michael Harris
>
>
>

Re: Verifying if file exists on href link by Tim

Tim
Fri Apr 25 15:21:20 CDT 2008

Function IsThere(sFile)
'...
p = Server.MapPath("../busops/prog") & "\"
IsThere = objFSO.FileExists(p & sFile)

end function

or something like that.

Tim


"omsoft" <omsoft@discussions.microsoft.com> wrote in message
news:CA02AB5D-44EB-4E06-B8E4-BFC22C3117F5@microsoft.com...
> Thanks Mike, I fixed that one. But it does not check for the file exists.
> I
> think I need to use FileExists, but am not sure of the implementation.
>
>
>
> "Michael Harris" wrote:
>
>> > ...
>> >
>> > I get an path not found error on the GetFolder line.
>> >
>> > Any help would be greatly appreciated.
>>
>> Try this:
>>
>> ....
>> Set objFolder = objFSO.GetFolder(Server.MapPath("../busops/prog"))
>> ....
>>
>> --
>> Michael Harris
>>
>>
>>