Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. reading a text file from the resource file

reading a text file from the resource file

Scheduled Pinned Locked Moved Visual Basic
learning
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    moonshaddow
    wrote on last edited by
    #1

    hi i am using a stream reader to read a text file from the resource file, i have tried two way to read each line and put it into i combobox but i get the following errors, can someone point out where i am going wrong, thanks in advance

    Using readfile As StreamReader = File.OpenText(My.Resources.mages)'Illegal characters in path.
    Do
    line = readfile.ReadLine
    My.Forms.Main.cbspells.Items.Add(line)
    Loop Until line Is Nothing
    readfile.Close()
    End Using

    Using readfile As StreamReader = New StreamReader(My.Resources.magea)'Empty path name is not legal.
    Do
    line = readfile.ReadLine
    My.Forms.Main.cbabilities.Items.Add(line)
    Loop Until line Is Nothing
    readfile.Close()
    End Using

    J.Hardy

    A 1 Reply Last reply
    0
    • M moonshaddow

      hi i am using a stream reader to read a text file from the resource file, i have tried two way to read each line and put it into i combobox but i get the following errors, can someone point out where i am going wrong, thanks in advance

      Using readfile As StreamReader = File.OpenText(My.Resources.mages)'Illegal characters in path.
      Do
      line = readfile.ReadLine
      My.Forms.Main.cbspells.Items.Add(line)
      Loop Until line Is Nothing
      readfile.Close()
      End Using

      Using readfile As StreamReader = New StreamReader(My.Resources.magea)'Empty path name is not legal.
      Do
      line = readfile.ReadLine
      My.Forms.Main.cbabilities.Items.Add(line)
      Loop Until line Is Nothing
      readfile.Close()
      End Using

      J.Hardy

      A Offline
      A Offline
      Ashutosh Phoujdar
      wrote on last edited by
      #2

      Can you please try something like this :

          Dim line As String
          For Each line In My.Resources.mages.Split(System.Environment.NewLine)
              If line <> String.Empty Then
                  My.Forms.Main.cbspells.Items.Add(line)
              End If
          Next
          For Each line In My.Resources.magea.Split(System.Environment.NewLine)
              If line <> String.Empty Then
                  My.Forms.Main.cbabilities.Items.Add(line)
              End If
          Next
      

      Since My.Resource.<<resource-name>> will return content of resource, and it is not suitable to reading with StreamReader. Please reply if this works for you :)

      dnpro "Very bad programmer" My Latest Articles RichTextBox Control with Find functionality LogViewer - A Simple Log Listening Utility

      M 1 Reply Last reply
      0
      • A Ashutosh Phoujdar

        Can you please try something like this :

            Dim line As String
            For Each line In My.Resources.mages.Split(System.Environment.NewLine)
                If line <> String.Empty Then
                    My.Forms.Main.cbspells.Items.Add(line)
                End If
            Next
            For Each line In My.Resources.magea.Split(System.Environment.NewLine)
                If line <> String.Empty Then
                    My.Forms.Main.cbabilities.Items.Add(line)
                End If
            Next
        

        Since My.Resource.<<resource-name>> will return content of resource, and it is not suitable to reading with StreamReader. Please reply if this works for you :)

        dnpro "Very bad programmer" My Latest Articles RichTextBox Control with Find functionality LogViewer - A Simple Log Listening Utility

        M Offline
        M Offline
        moonshaddow
        wrote on last edited by
        #3

        that works fine thank you :thumbsup:

        J.Hardy

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups