コード例 #1
0
        private void Move(string from, string to)
        {
            var fileop = new ShellNative.SHFILEOPSTRUCT
            {
                wFunc  = ShellNative.FO_MOVE,
                pFrom  = from,
                pTo    = to,
                fFlags = ShellNative.FOF_RENAMEONCOLLISION
            };

            ShellNative.SHFileOperation(ref fileop);
        }
コード例 #2
0
 private Task getDetails(DriveItem drive)
 {
     return(Task.Factory.StartNew(() =>
     {
         var info = new DriveInfo(drive.DisplayName);
         drive.Path = info.RootDirectory.FullName;
         drive.IsReady = info.IsReady;
         drive.DisplayName = drive.FilterString = GetDriveInfoString(info);
         var tmb = ShellNative.GetLargeBitmapSource(drive.Path);
         tmb.Freeze();
         drive.Thumbnail = tmb;
     }));
 }
コード例 #3
0
ファイル: ViewFileLister.cs プロジェクト: jueva/Kexi
        protected override async Task <IEnumerable <RtfItem> > GetItems()
        {
            Title     = Path;
            Thumbnail = ShellNative.GetLargeBitmapSource(Path);
            PathName  = System.IO.Path.GetFileName(Path);
            var extension = System.IO.Path.GetExtension(Path);
            var encoding  = GetEncoding();

            _syntaxHighlighter = new SyntaxHighlighter(encoding);
            if (encoding == null)
            {
                return(await Task.Run(() => _syntaxHighlighter.InitBinary(Path)));
            }
            return(await _syntaxHighlighter.Init(Path, extension));
        }
コード例 #4
0
 private static BaseItem GetBaseItem(string s)
 {
     try
     {
         var b         = new BaseItem(s);
         var enumValue =
             (Environment.SpecialFolder)Enum.Parse(typeof(Environment.SpecialFolder), b.DisplayName);
         b.Path      = Environment.GetFolderPath(enumValue);
         b.Thumbnail = ShellNative.GetLargeBitmapSource(b.Path);
         return(b);
     }
     catch (Exception)
     {
         return(null);
     }
 }
コード例 #5
0
        public static string Paste(string target, StringCollection items, FileAction action, short flags = ShellNative.FOF_ALLOWUNDO)
        {
            if (!Clipboard.ContainsFileDropList())
            {
                return(null);
            }

            if (action != FileAction.Copy && action != FileAction.Move && action != FileAction.Create)
            {
                throw new ArgumentOutOfRangeException(nameof(action), action, "Action should be Copy or Move");
            }

            var it   = items.Cast <string>().ToList();
            var from = string.Join("\0", it) + "\0";
            var to   = target + "\0";

            if (items.Count == 1)
            {
                var info = new FileInfo(items[0]);
                if (info.Directory.FullName.ToLower() == target.ToLower())
                {
                    flags = (short)(flags | ShellNative.FOF_RENAMEONCOLLISION);
                }
            }

            var fileop = new ShellNative.SHFILEOPSTRUCT
            {
                wFunc  = action == FileAction.Copy ? ShellNative.FO_COPY : ShellNative.FO_MOVE,
                pFrom  = from,
                pTo    = to,
                fFlags = flags
            };

            ShellNative.SHFileOperation(ref fileop);

            return($@"{target}\{it.LastOrDefault()}");
        }