Skip to content

Commit 1b6f3a1

Browse files
committed
Fixed Invalid characters for Windows filenames
1 parent 970678d commit 1b6f3a1

File tree

5 files changed

+21
-56
lines changed

5 files changed

+21
-56
lines changed

NoteWidgetAddIn/Export/AbstractExportor.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ private string ExportFileHierarchyRecursively(NoteNode parentNode, string hierar
7272
{
7373
if (parentNode.NodeType == NodeType.Page)
7474
{
75-
var file = Path.Combine(hierarchyFolderPath, parentNode.Name + FileExtension);
75+
var file = Path.Combine(hierarchyFolderPath, PathHelper.MakeValidFileName(parentNode.Name) + FileExtension);
7676
CreatePageFile(parentNode.ID, file);
7777
}
7878
string currentFolderPath;
7979
if (parentNode.NodeType != NodeType.Page || (parentNode.NodeType == NodeType.Page && parentNode.Children.Count > 0))
8080
{
81-
currentFolderPath = PathHelper.MakeUniqueFolderName(Path.Combine(hierarchyFolderPath, parentNode.Name));
81+
currentFolderPath = PathHelper.MakeUniqueFolderName(Path.Combine(hierarchyFolderPath, PathHelper.MakeValidFileName(parentNode.Name)));
8282
Directory.CreateDirectory(currentFolderPath);
8383
}
8484
else
@@ -99,13 +99,14 @@ protected string GetFullPathNodeName(NoteNode node, char seperatorChar)
9999
NoteNode tmp = node;
100100
while (tmp != null)
101101
{
102+
var nodeName = PathHelper.MakeValidFileName(tmp.Name);
102103
if (fileNameBuilder.Length == 0)
103104
{
104-
fileNameBuilder.Append(tmp.Name);
105+
fileNameBuilder.Append(nodeName);
105106
}
106107
else
107108
{
108-
fileNameBuilder.Insert(0, tmp.Name + seperatorChar.ToString());
109+
fileNameBuilder.Insert(0, nodeName + seperatorChar.ToString());
109110
}
110111
tmp = tmp.Parent;
111112
}

NoteWidgetAddIn/NoteWidgetAddIn.csproj

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -51,44 +51,14 @@
5151
<Reference Include="extensibility, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
5252
<EmbedInteropTypes>True</EmbedInteropTypes>
5353
</Reference>
54-
<Reference Include="HtmlAgilityPack, Version=1.11.40.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
55-
<HintPath>..\packages\HtmlAgilityPack.1.11.40\lib\Net45\HtmlAgilityPack.dll</HintPath>
56-
</Reference>
57-
<Reference Include="Markdig, Version=0.26.0.0, Culture=neutral, processorArchitecture=MSIL">
58-
<HintPath>..\packages\Markdig.0.26.0\lib\net452\Markdig.dll</HintPath>
59-
</Reference>
60-
<Reference Include="Microsoft.Web.WebView2.Core, Version=1.0.1054.31, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL">
61-
<HintPath>..\packages\Microsoft.Web.WebView2.1.0.1054.31\lib\net45\Microsoft.Web.WebView2.Core.dll</HintPath>
62-
</Reference>
63-
<Reference Include="Microsoft.Web.WebView2.WinForms, Version=1.0.1054.31, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL">
64-
<HintPath>..\packages\Microsoft.Web.WebView2.1.0.1054.31\lib\net45\Microsoft.Web.WebView2.WinForms.dll</HintPath>
65-
</Reference>
66-
<Reference Include="Microsoft.Web.WebView2.Wpf, Version=1.0.1054.31, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL">
67-
<HintPath>..\packages\Microsoft.Web.WebView2.1.0.1054.31\lib\net45\Microsoft.Web.WebView2.Wpf.dll</HintPath>
68-
</Reference>
69-
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
70-
<HintPath>..\packages\NLog.4.7.13\lib\net45\NLog.dll</HintPath>
71-
</Reference>
7254
<Reference Include="PresentationCore" />
7355
<Reference Include="PresentationFramework" />
7456
<Reference Include="System" />
75-
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
76-
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
77-
</Reference>
7857
<Reference Include="System.Configuration" />
7958
<Reference Include="System.Core" />
8059
<Reference Include="System.Drawing" />
8160
<Reference Include="System.IO.Compression" />
82-
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
83-
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
84-
</Reference>
8561
<Reference Include="System.Numerics" />
86-
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
87-
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
88-
</Reference>
89-
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
90-
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
91-
</Reference>
9262
<Reference Include="System.Runtime.Serialization" />
9363
<Reference Include="System.ServiceModel" />
9464
<Reference Include="System.Transactions" />
@@ -230,7 +200,6 @@
230200
<Content Include="NLog.config">
231201
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
232202
</Content>
233-
<None Include="packages.config" />
234203
<None Include="Properties\Settings.settings">
235204
<Generator>SettingsSingleFileGenerator</Generator>
236205
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -258,7 +227,20 @@
258227
<ItemGroup>
259228
<None Include="Properties\openfolder.png" />
260229
</ItemGroup>
261-
<ItemGroup />
230+
<ItemGroup>
231+
<PackageReference Include="HtmlAgilityPack">
232+
<Version>1.11.40</Version>
233+
</PackageReference>
234+
<PackageReference Include="Markdig">
235+
<Version>0.26.0</Version>
236+
</PackageReference>
237+
<PackageReference Include="Microsoft.Web.WebView2">
238+
<Version>1.0.1054.31</Version>
239+
</PackageReference>
240+
<PackageReference Include="NLog">
241+
<Version>4.7.13</Version>
242+
</PackageReference>
243+
</ItemGroup>
262244
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
263245
<PropertyGroup>
264246
<PreBuildEvent>if $(ConfigurationName) == Publish (
@@ -270,11 +252,4 @@ taskkill /fi "pid gt 0" /im ONENOTE.exe
270252
call C:\Users\efrey\source\Github\OneNoteWidget\powershell-copyfile-runas.bat "$(TargetPath)" "C:\Program Files (x86)\EKStudio\NoteWidget\$(TargetFileName)"
271253
)</PostBuildEvent>
272254
</PropertyGroup>
273-
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.1054.31\build\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.1054.31\build\Microsoft.Web.WebView2.targets')" />
274-
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
275-
<PropertyGroup>
276-
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
277-
</PropertyGroup>
278-
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.1054.31\build\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.1054.31\build\Microsoft.Web.WebView2.targets'))" />
279-
</Target>
280255
</Project>

NoteWidgetAddIn/packages.config

Lines changed: 0 additions & 11 deletions
This file was deleted.

NoteWidgetTests/DummyData/NotebookHierarchy.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</one:SectionGroup>
2929
<one:SectionGroup name="Backend" ID="{72F6EE87-4B69-405F-A5A8-63FA2D683444}{1}{B0}" path="C:\OneNote\UnitTestNote\Backend" lastModifiedTime="2021-12-21T07:57:54.000Z" isCurrentlyViewed="true">
3030
<one:Section name="Go" ID="{B75B0FB1-6DB5-4ED2-9C69-4060F8FB7FF8}{1}{B0}" path="C:\OneNote\UnitTestNote\Backend\Go.one" lastModifiedTime="2021-12-21T07:55:24.000Z" color="#EE9597" isCurrentlyViewed="true">
31-
<one:Page ID="{B75B0FB1-6DB5-4ED2-9C69-4060F8FB7FF8}{1}{E1954863573282337301011917182284793899649511}" name="Chapter 1" dateTime="2021-12-21T07:50:59.000Z" lastModifiedTime="2021-12-21T07:55:24.000Z" pageLevel="1" isCurrentlyViewed="true" />
31+
<one:Page ID="{B75B0FB1-6DB5-4ED2-9C69-4060F8FB7FF8}{1}{E1954863573282337301011917182284793899649511}" name="Chapter 1 |:*?|" dateTime="2021-12-21T07:50:59.000Z" lastModifiedTime="2021-12-21T07:55:24.000Z" pageLevel="1" isCurrentlyViewed="true" />
3232
</one:Section>
3333
<one:SectionGroup name="DotNet" ID="{6F8F683A-D9FE-4CDD-8605-8BAA00E742EA}{1}{B0}" path="C:\OneNote\UnitTestNote\Backend\DotNet" lastModifiedTime="2021-12-21T07:57:54.000Z">
3434
<one:Section name="CSharp" ID="{443F89FE-0C2F-41D2-8FCA-B54E1F45349B}{1}{B0}" path="C:\OneNote\UnitTestNote\Backend\DotNet\CSharp.one" lastModifiedTime="2021-12-21T07:56:53.000Z" color="#91BAAE">

NoteWidgetTests/DummyData/NotebookHierarchy_Expected.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</one:Section>
88
<one:SectionGroup name="Backend" ID="{72F6EE87-4B69-405F-A5A8-63FA2D683444}{1}{B0}" path="C:\OneNote\UnitTestNote\Backend" lastModifiedTime="2021-12-21T07:57:54.000Z" isCurrentlyViewed="true">
99
<one:Section name="Go" ID="{B75B0FB1-6DB5-4ED2-9C69-4060F8FB7FF8}{1}{B0}" path="C:\OneNote\UnitTestNote\Backend\Go.one" lastModifiedTime="2021-12-21T07:55:24.000Z" color="#EE9597" isCurrentlyViewed="true">
10-
<one:Page ID="{B75B0FB1-6DB5-4ED2-9C69-4060F8FB7FF8}{1}{E1954863573282337301011917182284793899649511}" name="Chapter 1" dateTime="2021-12-21T07:50:59.000Z" lastModifiedTime="2021-12-21T07:55:24.000Z" pageLevel="1" isCurrentlyViewed="true" />
10+
<one:Page ID="{B75B0FB1-6DB5-4ED2-9C69-4060F8FB7FF8}{1}{E1954863573282337301011917182284793899649511}" name="Chapter 1 -" dateTime="2021-12-21T07:50:59.000Z" lastModifiedTime="2021-12-21T07:55:24.000Z" pageLevel="1" isCurrentlyViewed="true" />
1111
</one:Section>
1212
<one:SectionGroup name="DotNet" ID="{6F8F683A-D9FE-4CDD-8605-8BAA00E742EA}{1}{B0}" path="C:\OneNote\UnitTestNote\Backend\DotNet" lastModifiedTime="2021-12-21T07:57:54.000Z">
1313
<one:Section name="CSharp" ID="{443F89FE-0C2F-41D2-8FCA-B54E1F45349B}{1}{B0}" path="C:\OneNote\UnitTestNote\Backend\DotNet\CSharp.one" lastModifiedTime="2021-12-21T07:56:53.000Z" color="#91BAAE">

0 commit comments

Comments
 (0)