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