1

当我尝试使用 Universal.torrent(UWP 的 monotorrent)从 .torrent 下载文件时,出现错误“访问路径 '...' 被拒绝” https://github.com/zumicts/Universal.Torrent .

这是我的代码:

private async void Torrenttest_Click(object sender, RoutedEventArgs e)
    {
        TorrentFunc tf = new TorrentFunc(ApplicationData.Current.LocalFolder);

        FileOpenPicker openPicker = new FileOpenPicker();
        openPicker.FileTypeFilter.Add(".torrent");
        openPicker.ViewMode = PickerViewMode.List;
        openPicker.SuggestedStartLocation = PickerLocationId.Desktop;
        StorageFile file = await openPicker.PickSingleFileAsync();

        tf.DownloadTorrent(file.Path);
    }

class TorrentFunc
{  
  ClientEngine engine;
  StorageFolder savePath;

     // savePath is the directory where downloads will be stored
     public TorrentFunc(StorageFolder Path)
     {
         // Create a basic ClientEngine without changing any settings
         this.engine = new ClientEngine(new EngineSettings());
         this.savePath = Path;
     }

    public async void DownloadTorrent(string path)
    {
        Torrent torrent = await Task.Run(() => Torrent.Load(path));
      //  StorageFolder storageFolder = await StorageFolder.GetFolderFromPathAsync(savePath);
        TorrentManager manager = new TorrentManager(torrent, savePath, new TorrentSettings());
        engine.Register(manager);
        manager.Start();
    }


}

错误出现在“Torrent torrent = await Task.Run(() => Torrent.Load(path));”行上

我尝试获取的文件在我的桌面上,它是一个简单的 .torrent 文件。

感谢您阅读本文,如果您有任何想法;)

4

0 回答 0