-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from NguyenDanPhuong/develop
Fix cannot save manga to another disk volume
- Loading branch information
Showing
6 changed files
with
63 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.IO; | ||
|
||
namespace MangaRipper.Core.Extensions | ||
{ | ||
public static class ExtensionHelper | ||
{ | ||
/// <summary> | ||
/// Remove characters that cannot using to name folder, file. | ||
/// </summary> | ||
/// <param name="input"></param> | ||
/// <returns></returns> | ||
public static string RemoveFileNameInvalidChar(this string input) | ||
{ | ||
return input.Replace("\\", "").Replace("/", "").Replace(":", "") | ||
.Replace("*", "").Replace("?", "").Replace("\"", "") | ||
.Replace("<", "").Replace(">", "").Replace("|", ""); | ||
} | ||
|
||
/// <summary> | ||
/// Directory.Move in C# cannot move across disk volume. | ||
/// So we have this SUPER MOVE!!! :) | ||
/// </summary> | ||
/// <param name="sourcePath"></param> | ||
/// <param name="destinationPath"></param> | ||
public static void SuperMove(string sourcePath, string destinationPath) | ||
{ | ||
CopyFolderAndAllSubItems(new DirectoryInfo(sourcePath), new DirectoryInfo(destinationPath)); | ||
} | ||
|
||
public static void CopyFolderAndAllSubItems(DirectoryInfo source, DirectoryInfo destination) | ||
{ | ||
foreach (DirectoryInfo dir in source.GetDirectories()) | ||
CopyFolderAndAllSubItems(dir, destination.CreateSubdirectory(dir.Name)); | ||
foreach (FileInfo file in source.GetFiles()) | ||
file.CopyTo(Path.Combine(destination.FullName, file.Name)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters