我是入门菜鸟!!! 
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Not Page.IsPostBack Then
            Dim count As Integer
            Dim stream As FileStream
            Dim pathname, datastr As String
            Dim strreadobj As StreamReader
            Dim strwriteobj As StreamWriter
            pathname = GetFileName()
            stream = New FileStream(pathname, FileMode.OpenorCreate, FileAccess.Read)
            strreadobj = New StreamReader(stream)
            datastr = strreadobj.ReadLine()
            strreadobj.close()
            count = CInt(datastr)
            count += 1
            TextBox1.Text = count
            stream = New FileStream(pathname, FileMode.Open, FileAccess.Write)
            strwriteobj = New StreamWriter(stream)
            strwriteobj.WriteLine(count)
            strwriteobj.close(()
        End If
    End Sub
编译运行时,出现
c:\inetpub\wwwroot\WebApplication1\WebForm1.aspx.vb(27): 未定义类型“FileStream”。
c:\inetpub\wwwroot\WebApplication1\WebForm1.aspx.vb(29): 未定义类型“StreamReader”。
c:\inetpub\wwwroot\WebApplication1\WebForm1.aspx.vb(30): 未定义类型“StreamWriter”。
c:\inetpub\wwwroot\WebApplication1\WebForm1.aspx.vb(31): 名称“GetFileName”未声明。请高手指导

解决方案 »

  1.   

    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="WebApplication1.WebForm1"%><%@ Import NameSpace="System.IO" %><script language="vb" runat="server">
    Function GetFileName() as String
    Dim fullpath as String
    Dim position as Integer
      fullpath=Request.ServerVariables("PATH_TRANSLATED")
      position=InstrRev(fullpath,".")
      GetFileName=Mid(fullpath,1,position)&"cnt"
    End Function
    </script>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
    <HEAD>
    <title>WebForm1</title>

    <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <FONT face="宋体"></FONT>访问量:
    <asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 64px; POSITION: absolute; TOP: 16px" runat="server"
    Width="64px"></asp:TextBox>
    </form>
    </body>
    </HTML>我在第三行已经添加了<%@ Import NameSpace="System.IO" %>
      

  2.   

    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="WebApplication1.WebForm1"%>---》<%@ Page Language="vb" %>
      

  3.   

    大哥,不行啊。还是出现上面的问题!!!
    c:\inetpub\wwwroot\WebApplication1\WebForm1.aspx.vb(27): 未定义类型“FileStream”。
    c:\inetpub\wwwroot\WebApplication1\WebForm1.aspx.vb(29): 未定义类型“StreamReader”。
    c:\inetpub\wwwroot\WebApplication1\WebForm1.aspx.vb(30): 未定义类型“StreamWriter”。
    c:\inetpub\wwwroot\WebApplication1\WebForm1.aspx.vb(31): 名称“GetFileName”未声明。
      

  4.   

    这些定义要写在.cs 文件中(codebehind 结构)
      

  5.   

    在你的 WebForm1.aspx.vb 里加命名空间,不是在 WebForm1.aspx 里加。
      

  6.   

    对啊,我就是在WebForm1.appx.vb中加入的