A
Arpan
If I am not wrong, System.IO is one of the seven namespaces that get
imported in all ASP.NET page automatically but in the following code:
<%@ Import Namespace="System.IO" %>
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")
lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
& "<br>"
lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
"<br>"
lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
End Sub
</script>
<form runat="server">
<asp:Label ID="lblOutput" runat="server">
</form>
if I get rid of the <%@ Import.....%> line, then ASP.NET generates the
following error:
Type 'FileInfo' is not defined.
pointing to the very first line within the Page_Load sub (Dim
ioFileInfo As New FileInfo...).
Why?
Please correct me if I am wrong.
Thanks,
Arpan
imported in all ASP.NET page automatically but in the following code:
<%@ Import Namespace="System.IO" %>
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp")
lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>"
lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
lblOutput.Text += Last Accessed: " & ioFileInfo.LastAccessTime
& "<br>"
lblOutput.Text += Last Written: " & ioFileInfo.LastWriteTime &
"<br>"
lblOutput.Text += Size: " & ioFileInfo.Length & " bytes"
End Sub
</script>
<form runat="server">
<asp:Label ID="lblOutput" runat="server">
</form>
if I get rid of the <%@ Import.....%> line, then ASP.NET generates the
following error:
Type 'FileInfo' is not defined.
pointing to the very first line within the Page_Load sub (Dim
ioFileInfo As New FileInfo...).
Why?
Please correct me if I am wrong.
Thanks,
Arpan