Reputation: 29
I get an error "Acces to the path '...' is denied" when i try to download a file from a .torrent using Universal.torrent (monotorrent for UWP) https://github.com/zumicts/Universal.Torrent.
Here my code :
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);
}
and
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();
}
}
The error appears on line "Torrent torrent = await Task.Run(() => Torrent.Load(path));"
The file that i try to get is on my desktop and it's a simple .torrent file.
Thank you for read this and if you have any idea ;)
Upvotes: 1
Views: 258