Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,

I am trying to write public properties form a class to a textfile but i wont work why?

This is my code :
C#
Type getPublicPropertiesType = (typeof(IOffer));
                PropertyInfo[] myPropertyInfo = getPublicPropertiesType.GetProperties(BindingFlags.Public | BindingFlags.Instance);


C#
StreamWriter log;

               if (!File.Exists("logg.txt"))
               {
                   log = new StreamWriter("logg.txt");
               }
               else
               {
                   log = File.AppendText("logg.txt");
               }


C#
log.WriteLine("The number of public properties is {0}.", myPropertyInfo.Length);
                log.Close();
Posted
Comments
[no name] 18-Jul-14 18:25pm    
Probably because you are writing "logg.txt" and the length of an array and not any property values?
George Jonsson 18-Jul-14 21:55pm    
Why do you want to write the properties to a text file?
An easy way would be to use XML.
Do you want to store the property names, the property values or both?

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