streamreader 未定义
Imports SystemImports
Public Class filedemotext
Dim myfilename As String = "c:\file.txt"
If file.exists(myfilename) Then
file.delete(myfilename)
End If
Dim sw As streamwriter = file.createtext(myfilename) '创建FILE.txt用于写数据
sw.writeline("file ")
sw.writeline("write ")
sw.writeline("string!")
sw.flush() '将缓冲的数据写入基础流
sw.close()
Try
Dim sr As streamreader = file.opentext(myfilename) '打开FILE.TXT用于读数据
Dim inputstring As String
inputstring = sr.readline()
While Not inputstring Is Nothing '检测不到文件尾时打印读出的结果
Console.WriteLine(inputstring)
inputstring = sr.readline()
End While
sr.close()
Catch error_info As Exception
Console.WriteLine("文件操作错误!" & error_info.ToString())
End Try
我运行后,有7处出错(下划线)Imports语法错误,streamreader未定义类型,class关键字作为标识符无效,file 未声明名称 请问怎么解决????????????