Skip to content

Commit

Permalink
Fixed not substringing file names properly for sorting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ynscription committed Jan 24, 2020
1 parent 0c603ca commit d937640
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Miharu Scan Helper/BackEnd/Chapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ public Chapter (string folderSrc) {

FileInfo[] sortedFiles = null;
try {
sortedFiles = files.OrderBy(x => Int32.Parse(x.Name.Substring(0, x.Name.IndexOf('.')))).ToArray();
sortedFiles = files.OrderBy(x => {
return Int32.Parse(x.Name.Substring(0, x.Name.IndexOf('.')));
}).ToArray();

}
catch (FormatException e) {
sortedFiles = files.OrderBy(x=> x.Name).ToArray();
Expand All @@ -61,10 +64,13 @@ public Chapter (string [] filesSrc) {
Pages = new List<Page>();
string [] sortedFiles = null;
try {
sortedFiles = filesSrc.OrderBy(x => Int32.Parse(x.Substring(x.LastIndexOf("\\"), x.IndexOf('.')))).ToArray();
sortedFiles = filesSrc.OrderBy(x => {
int lastSlash = x.LastIndexOf("\\") + 1;
return Int32.Parse(x.Substring(lastSlash, x.IndexOf('.') - lastSlash));
}).ToArray();
}
catch (FormatException e) {
sortedFiles = filesSrc.OrderBy(x=> x.Substring(x.LastIndexOf("\\"))).ToArray();
sortedFiles = filesSrc.OrderBy(x=> x.Substring(x.LastIndexOf("\\") + 1)).ToArray();
}

foreach (string file in sortedFiles) {
Expand Down

0 comments on commit d937640

Please sign in to comment.