private async void Pick_Click(object sender, RoutedEventArgs e)
        {
            FileCount.Text = "";
            Folder.Text    = "";
            Search.Text    = "";
            FolderPicker picker = new FolderPicker();

            picker.FileTypeFilter.Add("*");
            picker.ViewMode = PickerViewMode.List;
            picker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
            StorageFolder folder = await picker.PickSingleFolderAsync();

            if (folder != null)
            {
                var tok = Guid.NewGuid().ToString();
                fal.AddOrReplace(tok, folder, folder.Path);
                Folder.Text = folder.Path;
                await Task.Run(() => count = FCount(folder.Path, "\\*"));

                //count = await SlowCount(folder);
            }
            else
            {
                Debug.WriteLine($"Folder Error");
            }
            FileCount.Text = count.ToString();
            Search.Text    = searchtext;
        }
Exemplo n.º 2
0
        public async Task <bool> AddDatabaseAsync(IFile dbFile)
        {
            var token = dbFile.IdFromPath();

            _accessList.AddOrReplace(GetDatabaseToken(token), dbFile.AsStorageItem());

            var folder = await _folder;

            // Check if file already has been created
            var files = await folder.CreateFileQuery().GetFilesAsync();

            if (files.Any(f => string.Equals(f.Name, (string)token, StringComparison.OrdinalIgnoreCase)))
            {
                return(false);
            }

            // File doesn't exist, so we will now create it. We don't need any contents in, just to be present
            await folder.CreateFileAsync((string)token, CreationCollisionOption.FailIfExists);

            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Updates the amount of transferred bytes we store for a transfer that was recorded previously with RecordTransfer().
        /// </summary>
        /// <param name="friendNumber">Friend number of the transfer to update.</param>
        /// <param name="fileNumber">File number of the transfer to update.</param>
        /// <param name="transferredBytes">New amount of transferred bytes.</param>
        /// <returns></returns>
        public async Task UpdateTransfer(int friendNumber, int fileNumber, long transferredBytes)
        {
            var entry = FindEntry(friendNumber, fileNumber);

            if (entry.Token == null)
            {
                return;
            }

            var file = await _futureAccesList.GetFileAsync(entry.Token);

            var metadata = DeserializeMetadata(entry.Metadata);

            metadata.TransferredBytes = transferredBytes;

            _futureAccesList.AddOrReplace(entry.Token, file, SerializeMetadata(metadata));
        }
Exemplo n.º 4
0
 /// <summary>
 /// Adds the folder to the list of folders this app has access to;
 /// prior to this the user must have selected the provided folder
 /// using a folder picker.
 /// </summary>
 /// <param name="accessFolder">folder this app has permission to use</param>
 public static void Save(StorageFolder accessFolder)
 {
     FolderAccess.AddOrReplace(Tokenize(accessFolder.Path), accessFolder);
 }