Search code examples
c#fileinfosettings

FileInfo in UserSettings saves as Null?


I've looked at the FileInfo class and I see it is marked with the SerializableAttribute. I do not fully understand what this attribute indicates, but to me it suggests that the FileInfo class should serialize into the XML file into which the settings save, but that is not the case, as the FileInfo setting comes through as null when the project loads.

How can I save FileInfo into UserSettings?


Solution

  • You can't. XmlSerializer requires a parameter-less constructor - which FileInfo does not have. It's marked Serializable because there are other serializers that don't have the same requirement.

    Related question.