Пример #1
0
    public override bool Convert(object val, Type targetType, object parameter, System.Globalization.CultureInfo culture, out object result)
    {
      result = null;
      string filename = val as string;
      if (filename == null)
        return false;

      filename = System.IO.Path.GetInvalidFileNameChars().Aggregate(filename, (current, invalidFileNameChar) => current.Replace(invalidFileNameChar, '_'));

      var sfc = new StringFormatConverter();
      return sfc.Convert(filename, targetType, parameter, culture, out result);
    }
        public override bool Convert(object val, Type targetType, object parameter, System.Globalization.CultureInfo culture, out object result)
        {
            result = null;
            string filename = val as string;

            if (filename == null)
            {
                return(false);
            }

            filename = System.IO.Path.GetInvalidFileNameChars().Aggregate(filename, (current, invalidFileNameChar) => current.Replace(invalidFileNameChar, '_'));

            var sfc = new StringFormatConverter();

            return(sfc.Convert(filename, targetType, parameter, culture, out result));
        }