public static ValidatePathName ( string element, string exceptionMessage ) : void | ||
element | string | |
exceptionMessage | string | |
리턴 | void |
public static void SerializeXmlFile <T>(T obj, string fileName) { Validate.ValidatePathName(fileName, string.Format(Resources.PathDoesNotExistForElement, string.Empty, fileName)); Validate.ValidateStringIsNullOrEmpty(fileName, string.Empty); XmlSerializer xmlSerializer = new XmlSerializer(typeof(T)); Encoding encoding = GetFileEncoding(fileName); using (TextWriter writer = new StreamWriter(new FileStream(fileName, FileMode.Create), encoding)) { xmlSerializer.Serialize(writer, obj); } }
public static void SerializeXmlFile <T>(T obj, string fileName) { Validate.ValidatePathName(fileName, String.Format(Resources.PathDoesNotExistForElement, String.Empty, fileName)); Validate.ValidateStringIsNullOrEmpty(fileName, String.Empty); XmlSerializer xmlSerializer = new XmlSerializer(typeof(T)); StringBuilder sBuilder = new StringBuilder(); using (StringWriter writer = new StringWriter(sBuilder)) { xmlSerializer.Serialize(writer, obj); } FileUtilities.DataStore.WriteFile(fileName, sBuilder.ToString(), Encoding.Unicode); }