Exemple #1
0
 private async Task MoveToTrashAsync(string filePath, CancellationToken token)
 {
     await ShouldExecute(async (t) =>
     {
         await Ensure(_trashFolder, t);
         //new ZlpFileInfo(filePath).Attributes = FileAttributes.Normal;
         if (await _fs.FileExistAsync(filePath, t))
         {
             var newPath = await GetTmpFileAsync(_trashFolder, t);
             await _fs.SetAttributesAsync(filePath, FileAttributes.Normal, t);
             await _fs.MoveAsync(filePath, newPath, t);
         }
     }, token);
 }
Exemple #2
0
            public async Task CopyToAsync(string path, CancellationToken token, bool createHardLink)
            {
                if (string.IsNullOrWhiteSpace(path))
                {
                    throw new ArgumentNullException("Target path is null or empty.");
                }

                if (Stream != null)
                {
                    using (var fstream = await _fs.OpenCreateAsync(path, token))
                    {
                        await Stream.CopyToAsync(fstream, _uploadBufferSize, token);
                    }
                }
                else
                {
                    if (createHardLink)
                    {
                        await _fs.CreateHardLinkAsync(FilePath, path, token);
                    }
                    else
                    {
                        await _fs.CopyFileAsync(FilePath, path, token);
                    }
                }
                await _fs.SetAttributesAsync(path, FileAttributes.Normal, token);
            }