Remove illegal characters from the download path.
This commit is contained in:
parent
1b082c3cd1
commit
a1e9b00d2d
1 changed files with 10 additions and 1 deletions
|
|
@ -14,8 +14,10 @@ public static class DownloadHelper
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var directory = RemoveInvalidChars(torrent.RdName);
|
||||||
|
|
||||||
var uri = new Uri(fileUrl);
|
var uri = new Uri(fileUrl);
|
||||||
var torrentPath = Path.Combine(downloadPath, torrent.RdName);
|
var torrentPath = Path.Combine(downloadPath, directory);
|
||||||
|
|
||||||
if (!Directory.Exists(torrentPath))
|
if (!Directory.Exists(torrentPath))
|
||||||
{
|
{
|
||||||
|
|
@ -26,8 +28,15 @@ public static class DownloadHelper
|
||||||
|
|
||||||
fileName = HttpUtility.UrlDecode(fileName);
|
fileName = HttpUtility.UrlDecode(fileName);
|
||||||
|
|
||||||
|
fileName = RemoveInvalidChars(fileName);
|
||||||
|
|
||||||
var filePath = Path.Combine(torrentPath, fileName);
|
var filePath = Path.Combine(torrentPath, fileName);
|
||||||
|
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String RemoveInvalidChars(String filename)
|
||||||
|
{
|
||||||
|
return String.Concat(filename.Split(Path.GetInvalidFileNameChars()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue