Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to replace special chars in temp filename #42

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions OutlookFileDrag.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio Version 16
VisualStudioVersion = 16.0.31005.135
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OutlookFileDrag", "OutlookFileDrag\OutlookFileDrag.csproj", "{88E6522A-C68B-42C8-8B5E-9C959BA6C415}"
EndProject
Expand All @@ -27,8 +27,8 @@ Global
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{88E6522A-C68B-42C8-8B5E-9C959BA6C415}.CD_ROM|Any CPU.ActiveCfg = Release|Any CPU
{88E6522A-C68B-42C8-8B5E-9C959BA6C415}.CD_ROM|Any CPU.Build.0 = Release|Any CPU
{88E6522A-C68B-42C8-8B5E-9C959BA6C415}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88E6522A-C68B-42C8-8B5E-9C959BA6C415}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88E6522A-C68B-42C8-8B5E-9C959BA6C415}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{88E6522A-C68B-42C8-8B5E-9C959BA6C415}.Debug|Any CPU.Build.0 = Release|Any CPU
{88E6522A-C68B-42C8-8B5E-9C959BA6C415}.DVD-5|Any CPU.ActiveCfg = Debug|Any CPU
{88E6522A-C68B-42C8-8B5E-9C959BA6C415}.DVD-5|Any CPU.Build.0 = Debug|Any CPU
{88E6522A-C68B-42C8-8B5E-9C959BA6C415}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -37,8 +37,8 @@ Global
{88E6522A-C68B-42C8-8B5E-9C959BA6C415}.SingleImage|Any CPU.Build.0 = Release|Any CPU
{B42086D0-8877-4CF2-B3FE-C19210CD683D}.CD_ROM|Any CPU.ActiveCfg = Release
{B42086D0-8877-4CF2-B3FE-C19210CD683D}.CD_ROM|Any CPU.Build.0 = Release
{B42086D0-8877-4CF2-B3FE-C19210CD683D}.Debug|Any CPU.ActiveCfg = Debug
{B42086D0-8877-4CF2-B3FE-C19210CD683D}.Debug|Any CPU.Build.0 = Debug
{B42086D0-8877-4CF2-B3FE-C19210CD683D}.Debug|Any CPU.ActiveCfg = Release
{B42086D0-8877-4CF2-B3FE-C19210CD683D}.Debug|Any CPU.Build.0 = Release
{B42086D0-8877-4CF2-B3FE-C19210CD683D}.DVD-5|Any CPU.ActiveCfg = Debug
{B42086D0-8877-4CF2-B3FE-C19210CD683D}.DVD-5|Any CPU.Build.0 = Debug
{B42086D0-8877-4CF2-B3FE-C19210CD683D}.Release|Any CPU.ActiveCfg = Release
Expand All @@ -47,8 +47,8 @@ Global
{B42086D0-8877-4CF2-B3FE-C19210CD683D}.SingleImage|Any CPU.Build.0 = Release
{0EF72B7A-7619-4572-A1C1-B31938BC6954}.CD_ROM|Any CPU.ActiveCfg = Release
{0EF72B7A-7619-4572-A1C1-B31938BC6954}.CD_ROM|Any CPU.Build.0 = Release
{0EF72B7A-7619-4572-A1C1-B31938BC6954}.Debug|Any CPU.ActiveCfg = Debug
{0EF72B7A-7619-4572-A1C1-B31938BC6954}.Debug|Any CPU.Build.0 = Debug
{0EF72B7A-7619-4572-A1C1-B31938BC6954}.Debug|Any CPU.ActiveCfg = Release
{0EF72B7A-7619-4572-A1C1-B31938BC6954}.Debug|Any CPU.Build.0 = Release
{0EF72B7A-7619-4572-A1C1-B31938BC6954}.DVD-5|Any CPU.ActiveCfg = Debug
{0EF72B7A-7619-4572-A1C1-B31938BC6954}.DVD-5|Any CPU.Build.0 = Debug
{0EF72B7A-7619-4572-A1C1-B31938BC6954}.Release|Any CPU.ActiveCfg = Release
Expand All @@ -59,4 +59,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8EDF0B53-AA52-4D87-B7D8-365DA197DF9D}
EndGlobalSection
EndGlobal
21 changes: 21 additions & 0 deletions OutlookFileDrag/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<root>
<level value="INFO" />
<appender-ref ref="RollingFileAppender" />
<appender-ref ref="OutputDebugStringAppender" />
</root>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="${APPDATA}\OutlookFileDrag\OutlookFileDrag.log" />
Expand All @@ -19,11 +20,31 @@
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
<appender name="OutputDebugStringAppender" type="log4net.Appender.OutputDebugStringAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[OutlookFileDrag] %level %date{HH:mm:ss,fff} - %message%n" />
</layout>
</appender>
</log4net>
<appSettings>
<!-- Sets the cleanup timer interval in minutes -->
<add key="CleanupTimerInterval" value="60" />
<!-- Sets the temp file expiration in minutes -->
<add key="TempFileExpiration" value="60" />
<!-- Replaces all non a-z,A-Z,0-9 characters with underline character '_' -->
<add key="ReplaceSpecialChars" value="true" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
</providers>
</roleManager>
</system.web>
</configuration>
Binary file modified OutlookFileDrag/EasyHook32.dll
Binary file not shown.
Binary file modified OutlookFileDrag/EasyHook64.dll
Binary file not shown.
16 changes: 16 additions & 0 deletions OutlookFileDrag/FileUtility.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Text.RegularExpressions;
using log4net;

namespace OutlookFileDrag
Expand Down Expand Up @@ -57,6 +58,21 @@ public static string GetUniqueFilename(string filename)
ext = Path.GetExtension(filename);
filename = filename.Substring(0, NativeMethods.MAX_PATH - ext.Length - 1) + ext;
}

bool replaceSpecialChars = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["ReplaceSpecialChars"]);

if (replaceSpecialChars)
{
string justPath = Path.GetDirectoryName(filename);
string justFilenameNoExt = Path.GetFileNameWithoutExtension(filename);
string justExt = Path.GetExtension(filename);

string justFilenameNoExtSimple = Regex.Replace(justFilenameNoExt, @"[^a-z,A-Z,0-9]+", "_");

log.Info("Using " + justFilenameNoExtSimple + justExt + " as CF_HDROP filename instead of "+justFilenameNoExt + justExt);

filename = Path.Combine(justPath, justFilenameNoExtSimple + justExt);
}

//If file does not exist, use original filename
if (!File.Exists(filename))
Expand Down
29 changes: 13 additions & 16 deletions OutlookFileDrag/OutlookFileDrag.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,11 @@
-->
<ItemGroup>
<Reference Include="Accessibility" />
<Reference Include="EasyHook, Version=2.7.6578.0, Culture=neutral, PublicKeyToken=4b580fca19d0b0c5, processorArchitecture=MSIL">
<HintPath>..\packages\EasyHook.2.7.6578.1\lib\net40\EasyHook.dll</HintPath>
<Private>True</Private>
<Reference Include="EasyHook, Version=2.7.7097.0, Culture=neutral, PublicKeyToken=4b580fca19d0b0c5, processorArchitecture=MSIL">
<HintPath>..\packages\EasyHook.2.7.7097\lib\net40\EasyHook.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.8\lib\net40-full\log4net.dll</HintPath>
<Private>True</Private>
<Reference Include="log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.12\lib\net40\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
Expand All @@ -146,6 +144,7 @@
<Reference Include="System.Data.Entity" />
<Reference Include="System.Drawing" />
<Reference Include="System.Runtime.Remoting" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
Expand Down Expand Up @@ -206,12 +205,11 @@
<SubType>Designer</SubType>
</None>
<None Include="OutlookFileDrag.pfx" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
<Compile Include="ThisAddIn.cs">
<SubType>Code</SubType>
</Compile>
<None Include="OutlookFileDrag_TemporaryKey.pfx" />
<None Include="packages.config" />
<None Include="ThisAddIn.Designer.xml">
<DependentUpon>ThisAddIn.cs</DependentUpon>
</None>
Expand All @@ -221,12 +219,12 @@
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<None Include="EasyHook32.dll">
<Content Include="EasyHook32.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="EasyHook64.dll">
</Content>
<Content Include="EasyHook64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</Content>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
Expand All @@ -236,11 +234,10 @@
<SignManifests>true</SignManifests>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>
</ManifestKeyFile>
<ManifestKeyFile>OutlookFileDrag_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>6EA39ECAD013020F956462F4CBF07570C217A1CF</ManifestCertificateThumbprint>
<ManifestCertificateThumbprint>7B2FEE5704ED6752FF5B25911F0704E95117A787</ManifestCertificateThumbprint>
</PropertyGroup>
<!-- Include the build rules for a C# project. -->
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
6 changes: 3 additions & 3 deletions OutlookFileDrag/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Outlook File Drag")]
[assembly: AssemblyDescription("Drag and drop Outlook items and attachments as files into any application")]
[assembly: AssemblyDescription("Drag and drop Outlook items and attachments as files into any application (and replace special chars)")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Tony Federer")]
[assembly: AssemblyProduct("Outlook File Drag")]
Expand All @@ -33,6 +33,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.11.0")]
[assembly: AssemblyFileVersion("1.0.11.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]

4 changes: 2 additions & 2 deletions OutlookFileDrag/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EasyHook" version="2.7.6578.1" targetFramework="net40" />
<package id="log4net" version="2.0.8" targetFramework="net40" />
<package id="EasyHook" version="2.7.7097" targetFramework="net40" />
<package id="log4net" version="2.0.12" targetFramework="net40" />
</packages>
2 changes: 1 addition & 1 deletion OutlookFileDragSetup/OutlookFileDragSetup.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:TRUE"
"ProductVersion" = "8:1.0.11"
"ProductVersion" = "8:1.1.0"
"Manufacturer" = "8:Tony Federer"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:https://github.com/tonyfederer/OutlookFileDrag"
Expand Down
2 changes: 1 addition & 1 deletion OutlookFileDragSetup_x64/OutlookFileDragSetup_x64.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:TRUE"
"ProductVersion" = "8:1.0.11"
"ProductVersion" = "8:1.1.0"
"Manufacturer" = "8:Tony Federer"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:https://github.com/tonyfederer/OutlookFileDrag"
Expand Down