Click here to Skip to main content
15,905,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I use this code for read a text file in C# WindowsForm
But now When I use it in asp.net Webform I get Error , That mean stream is null ...

C#
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("WAT.AppCode.countries.tsv"))
           {
               StreamReader streamReader = new StreamReader(stream, false);
               string text;
               while ((text = streamReader.ReadLine()) != null)
               {
                   if (text.Length != 0)
                   {
                       CountryEntry cii = new CountryEntry(text);
                       this.Add(cii);
                   }
               }
           }
Posted
Comments
Kornfeld Eliyahu Peter 10-Feb-15 4:45am    
Check the differences between the executing assembly in case of WinForm (probably your exe) and in case of WebForm (the assembly linked to the current page, or the assembly holding the method the code belongs to)...Where your countries.tsv is in that context?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900