diff --git a/Source/FileManager/LongPath.cs b/Source/FileManager/LongPath.cs
index 535da6d0..36258da1 100644
--- a/Source/FileManager/LongPath.cs
+++ b/Source/FileManager/LongPath.cs
@@ -52,15 +52,36 @@ namespace FileManager
}
}
- public static implicit operator string(LongPath path) => path?.Path ?? null;
+ public static implicit operator string(LongPath path) => path?.Path;
[JsonIgnore]
public string ShortPathName
{
get
{
+ //Short Path names are useful for navigating to the file in windows explorer,
+ //which will not recognize paths longer than MAX_PATH. Short path names are not
+ //always enabled on every volume. So to check if a volume enables short path
+ //names (aka 8dot3 names), run the following command from an elevated command
+ //prompt:
+ //
+ // fsutil 8dot3name query c:
+ //
+ //It will say:
+ //
+ // "Based on the above settings, 8dot3 name creation is [enabled/disabled] on c:"
+ //
+ //To enable short names on all volumes on the system, run the following command
+ //from an elevated command prompt:
+ //
+ // fsutil 8dot3name set c: 0
+ //
+ //Note that after enabling 8dot3 names on a volume, they will only be available
+ //for newly-created entries in ther file system. Existing entries made while
+ //8dot3 names were disabled will not be reachable by short paths.
+
if (Path is null) return null;
- GetShortPathName(Path, longPathBuffer, MAX_PATH);
+ GetShortPathName(Path, longPathBuffer, MaxPathLength);
return longPathBuffer.ToString();
}
}
@@ -84,9 +105,9 @@ namespace FileManager
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
- private static extern int GetShortPathName(string path, StringBuilder shortPath, int shortPathLength);
+ private static extern int GetShortPathName([MarshalAs(UnmanagedType.LPWStr)] string path, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder shortPath, int shortPathLength);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
- private static extern int GetLongPathName(string lpszShortPath, StringBuilder lpszLongPath, int cchBuffer);
+ private static extern int GetLongPathName([MarshalAs(UnmanagedType.LPWStr)] string lpszShortPath, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lpszLongPath, int cchBuffer);
}
}
diff --git a/Source/LibationWinForms/Dialogs/SettingsDialog.Important.cs b/Source/LibationWinForms/Dialogs/SettingsDialog.Important.cs
index af2bdb37..505edb43 100644
--- a/Source/LibationWinForms/Dialogs/SettingsDialog.Important.cs
+++ b/Source/LibationWinForms/Dialogs/SettingsDialog.Important.cs
@@ -52,12 +52,6 @@ namespace LibationWinForms.Dialogs
return;
}
- if (!Directory.Exists(newBooks) && booksSelectControl.SelectedDirectoryIsCustom)
- {
- validationError($"Not saving change to Books location. This folder does not exist:\r\n{newBooks}", "Folder does not exist");
- return;
- }
-
// these 3 should do nothing. Configuration will only init these with a valid value. EditTemplateDialog ensures valid before returning
if (!Templates.Folder.IsValid(folderTemplateTb.Text))
{
@@ -76,8 +70,9 @@ namespace LibationWinForms.Dialogs
}
#endregion
- if (!Directory.Exists(newBooks) && booksSelectControl.SelectedDirectoryIsKnown)
- Directory.CreateDirectory(newBooks);
+ LongPath lonNewBooks = newBooks;
+ if (!Directory.Exists(lonNewBooks))
+ Directory.CreateDirectory(lonNewBooks);
config.Books = newBooks;
diff --git a/Source/LibationWinForms/LibationWinForms.csproj b/Source/LibationWinForms/LibationWinForms.csproj
index 7fab1293..94dd14ae 100644
--- a/Source/LibationWinForms/LibationWinForms.csproj
+++ b/Source/LibationWinForms/LibationWinForms.csproj
@@ -37,18 +37,17 @@
-
Form1.cs
-
-
- Dialogs\SettingsDialog.cs
-
-
+
+
+ SettingsDialog.cs
+
+