A
Arpan
A file named Form1.asp exists in the folder C:\Inetpub. The following
code exists in a file named FindFile.aspx which exists in
C:\Inetpub\wwwroot\ASPX:
<script runat="server">
Sub Page_Load(obj As Object, ea As EventArgs)
Dim ioFileInfo As FileInfo
ioFileInfo = New FileInfo(Server.MapPath("../../Form1.asp"))
If (ioFileInfo.Exists) Then
Response.Write("File Exists")
Else
Response.Write("File Doesnot Exist")
End If
End Sub
</script>
Now since FindFile.aspx exists in the folder C:\Inetpub\wwwroot\ASPX &
the file I am searching for (Form1.asp) exists in C:\Inetpub, I have to
move up by 2 folders which is why I have used ../ twice in
Server.MapPath but ASP.NET generates the following error:
Cannot use a leading .. to exit above the top directory.
pointing to the Server.MapPath line. How do I detect the existence of
Form1.asp in C:\Inetpub?
Thanks,
Arpan
code exists in a file named FindFile.aspx which exists in
C:\Inetpub\wwwroot\ASPX:
<script runat="server">
Sub Page_Load(obj As Object, ea As EventArgs)
Dim ioFileInfo As FileInfo
ioFileInfo = New FileInfo(Server.MapPath("../../Form1.asp"))
If (ioFileInfo.Exists) Then
Response.Write("File Exists")
Else
Response.Write("File Doesnot Exist")
End If
End Sub
</script>
Now since FindFile.aspx exists in the folder C:\Inetpub\wwwroot\ASPX &
the file I am searching for (Form1.asp) exists in C:\Inetpub, I have to
move up by 2 folders which is why I have used ../ twice in
Server.MapPath but ASP.NET generates the following error:
Cannot use a leading .. to exit above the top directory.
pointing to the Server.MapPath line. How do I detect the existence of
Form1.asp in C:\Inetpub?
Thanks,
Arpan