public static ValidateStringIsNullOrEmpty ( string data, string messageData, bool useDefaultMessage = true ) : void | ||
data | string | string variable to validate |
messageData | string | This parameter is used when the validation fails. It can contain actual message to display /// or parameter name to display with default message |
useDefaultMessage | bool | Indicates either to use messageData as actual message or parameter name |
리턴 | void |
/// <summary> /// Ensures that a directory exists beofre attempting to write a file /// </summary> /// <param name="pathName">The path to the file that will be created</param> public static void EnsureDirectoryExists(string pathName) { Validate.ValidateStringIsNullOrEmpty(pathName, "Settings directory"); string directoryPath = Path.GetDirectoryName(pathName); if (!DataStore.DirectoryExists(directoryPath)) { DataStore.CreateDirectory(directoryPath); } }
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); }