reading a text file from the resource file
-
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 UsingUsing 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 UsingJ.Hardy
-
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 UsingUsing 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 UsingJ.Hardy
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
-
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
that works fine thank you :thumbsup:
J.Hardy