CODEKILLER

반응형

XmlSerializer 를 이용하여 Write하는 기본 예제.

Xml 파일에 개체를 Write.

public class Example
{
    public static void Main()
    {
        WriteXML(); 
    }
	
    public class CodeKiller  
    {  
        public String code;
    }  
  
    public static void WriteXML()  
    {  
        CodeKiller overview = new CodeKiller();  
        overview.code = "Serialization Overview";  
        System.Xml.Serialization.XmlSerializer writer =
            new System.Xml.Serialization.XmlSerializer(typeof(CodeKiller));  
  
        var path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "//Sample.xml";  
        System.IO.FileStream file = System.IO.File.Create(path);  
  
        writer.Serialize(file, overview);  
        file.Close();  
    } 
}
반응형

공유하기

facebook twitter kakaoTalk kakaostory naver band