I want to include certain files in my page. I'm not always sure if they exists, so I have to check if they do. (Otherwise the page crashes, as you probably know)
<%@ Page Language="C#" %>
<html>
<body>
<% bool exists;
exists = System.IO.File.Exists("/extra/file/test.txt");
%>
Test include:<br>
<!--#include file="/extra/file/test.txt"-->
</body>
</html>
</html>
While the include works, the code checking if the file exists does not.
If I remove this code:
<% bool exists;
exists = System.IO.File.Exists("/extra/file/test.txt");
%>
Everything runs fine.
I also tried putting it in a <script runat="server">
block, but it still failed.