コード例 #1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string _path = value as string;

            if (File.Exists(_path))
            {
                if (_path.Length > 240)  // 规避文件名和路径名过长问题
                {
                    if (!Directory.Exists("./temp"))
                    {
                        Directory.CreateDirectory("./temp");
                    }
                    FileInfo fi   = new FileInfo(_path);
                    string   _tmp = Path.GetFileName(_path);
                    if (!File.Exists("./temp/" + _tmp))
                    {
                        fi.CopyTo("./temp/" + _tmp, true);
                    }
                    return(new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + @"./temp/" + _tmp, UriKind.RelativeOrAbsolute)));
                }
                else
                {
                    return(new BitmapImage(new Uri(_path, UriKind.RelativeOrAbsolute)));
                }
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
 public override FileInfoBase CopyTo(string destFileName)
 {
     return(new FileInfoWrapper(FileSystem, instance.CopyTo(destFileName)));
 }