Using a .txt file Resource in VB

后端 未结 3 1489
野趣味
野趣味 2020-12-10 18:42

Right now i have a line of code, in vb, that calls a text file, like this:

Dim fileReader As String
    fileReader = My.Computer.FileSystem.ReadAllText(\"dat         


        
3条回答
  •  隐瞒了意图╮
    2020-12-10 19:03

    First, go to project resources (My Project --> Resources), and drag-and-drop your file, say "myfile.txt", from the file system to the resourses page. Then:

        Imports System.IO
        ...
        Dim stream As New MemoryStream(My.Resources.myfile)
        Dim reader As New StreamReader(stream)
        Dim s As String = reader.ReadToEnd()
    

提交回复
热议问题