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

Adding a .NET assembly to nicely interface WinSparkle.dll #55

Closed
wants to merge 4 commits into from
Closed
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
47 changes: 47 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,50 @@ ipch
3rdparty/wxWidgets/build/msw/*_*/
3rdparty/expat/win32/bin
3rdparty/expat/win32/tmp


## Visual Studio for .NET ignores
# NuGet Packages Directory
packages

# User-specific files
*.suo
*.user
*.sln.docstates

# Build Folders
[Bb]in/
[Oo]bj/

# Build results
[Dd]ebug/
[Rr]elease/
x64/
*_i.c
*_p.c
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.log
*.vspscc
*.vssscc
.builds

# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML

# ReSharper is a .NET coding add-in
_ReSharper*
126 changes: 124 additions & 2 deletions WinSparkle-2013.sln
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinSparkle", "WinSparkle-2013.vcxproj", "{524CCCF2-61EA-5B64-A1D9-FF5497027B5F}"
ProjectSection(ProjectDependencies) = postProject
{47B228CB-24FE-5250-B1FC-DFC81D3E69DF} = {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}
{499A5238-5AAC-5FD3-8902-819D787108A5} = {499A5238-5AAC-5FD3-8902-819D787108A5}
{47B228CB-24FE-5250-B1FC-DFC81D3E69DF} = {47B228CB-24FE-5250-B1FC-DFC81D3E69DF}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinSparkle_expat", "3rdparty\expat-2013.vcxproj", "{47B228CB-24FE-5250-B1FC-DFC81D3E69DF}"
Expand All @@ -20,52 +20,174 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_psdk", "examples\ex
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dependencies", "dependencies", "{2C4E4846-FF11-55AD-AFD1-BC1F3AF74724}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinSparkleDotNet", "src\WinSparkleDotNet\WinSparkleDotNet.csproj", "{B477D6EA-E4AA-40B2-A129-48D2656DAAAF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dotnet", "dotnet", "{06DF5654-1CEC-4113-88D8-6CBB985AB74D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinSparkleDotNetExample", "src\WinSparkleDotNetExample\WinSparkleDotNetExample.csproj", "{83A2FE2B-A06C-4475-B9A2-9F2BE6072A62}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppcastTestHost", "src\AppcastTestHost\AppcastTestHost.csproj", "{39D22122-C1DB-481C-A306-D746835E1701}"
EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "WinSparkleDotNetExampleInstaller", "src\WinSparkleDotNetExampleInstaller\WinSparkleDotNetExampleInstaller.wixproj", "{0E45ACDA-4EB0-4D9D-AD82-80A057E98899}"
ProjectSection(ProjectDependencies) = postProject
{83A2FE2B-A06C-4475-B9A2-9F2BE6072A62} = {83A2FE2B-A06C-4475-B9A2-9F2BE6072A62}
{B477D6EA-E4AA-40B2-A129-48D2656DAAAF} = {B477D6EA-E4AA-40B2-A129-48D2656DAAAF}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|Win32 = Release|Win32
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Debug|Any CPU.ActiveCfg = Debug|Win32
{524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Debug|Win32.ActiveCfg = Debug|Win32
{524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Debug|Win32.Build.0 = Debug|Win32
{524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Debug|x64.ActiveCfg = Debug|x64
{524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Debug|x64.Build.0 = Debug|x64
{524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Debug|x86.ActiveCfg = Debug|Win32
{524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Debug|x86.Build.0 = Debug|Win32
{524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Release|Any CPU.ActiveCfg = Release|Win32
{524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Release|Mixed Platforms.Build.0 = Release|Win32
{524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Release|Win32.ActiveCfg = Release|Win32
{524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Release|Win32.Build.0 = Release|Win32
{524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Release|x64.ActiveCfg = Release|x64
{524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Release|x64.Build.0 = Release|x64
{524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Release|x86.ActiveCfg = Release|Win32
{524CCCF2-61EA-5B64-A1D9-FF5497027B5F}.Release|x86.Build.0 = Release|Win32
{47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Debug|Any CPU.ActiveCfg = Debug|Win32
{47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Debug|Win32.ActiveCfg = Debug|Win32
{47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Debug|Win32.Build.0 = Debug|Win32
{47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Debug|x64.ActiveCfg = Debug|x64
{47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Debug|x64.Build.0 = Debug|x64
{47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Debug|x86.ActiveCfg = Debug|Win32
{47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Debug|x86.Build.0 = Debug|Win32
{47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Release|Any CPU.ActiveCfg = Release|Win32
{47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Release|Mixed Platforms.Build.0 = Release|Win32
{47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Release|Win32.ActiveCfg = Release|Win32
{47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Release|Win32.Build.0 = Release|Win32
{47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Release|x64.ActiveCfg = Release|x64
{47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Release|x64.Build.0 = Release|x64
{47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Release|x86.ActiveCfg = Release|Win32
{47B228CB-24FE-5250-B1FC-DFC81D3E69DF}.Release|x86.Build.0 = Release|Win32
{499A5238-5AAC-5FD3-8902-819D787108A5}.Debug|Any CPU.ActiveCfg = Debug|Win32
{499A5238-5AAC-5FD3-8902-819D787108A5}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{499A5238-5AAC-5FD3-8902-819D787108A5}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{499A5238-5AAC-5FD3-8902-819D787108A5}.Debug|Win32.ActiveCfg = Debug|Win32
{499A5238-5AAC-5FD3-8902-819D787108A5}.Debug|Win32.Build.0 = Debug|Win32
{499A5238-5AAC-5FD3-8902-819D787108A5}.Debug|x64.ActiveCfg = Debug|x64
{499A5238-5AAC-5FD3-8902-819D787108A5}.Debug|x64.Build.0 = Debug|x64
{499A5238-5AAC-5FD3-8902-819D787108A5}.Debug|x86.ActiveCfg = Debug|Win32
{499A5238-5AAC-5FD3-8902-819D787108A5}.Debug|x86.Build.0 = Debug|Win32
{499A5238-5AAC-5FD3-8902-819D787108A5}.Release|Any CPU.ActiveCfg = Release|Win32
{499A5238-5AAC-5FD3-8902-819D787108A5}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{499A5238-5AAC-5FD3-8902-819D787108A5}.Release|Mixed Platforms.Build.0 = Release|Win32
{499A5238-5AAC-5FD3-8902-819D787108A5}.Release|Win32.ActiveCfg = Release|Win32
{499A5238-5AAC-5FD3-8902-819D787108A5}.Release|Win32.Build.0 = Release|Win32
{499A5238-5AAC-5FD3-8902-819D787108A5}.Release|x64.ActiveCfg = Release|x64
{499A5238-5AAC-5FD3-8902-819D787108A5}.Release|x64.Build.0 = Release|x64
{499A5238-5AAC-5FD3-8902-819D787108A5}.Release|x86.ActiveCfg = Release|Win32
{499A5238-5AAC-5FD3-8902-819D787108A5}.Release|x86.Build.0 = Release|Win32
{AFBD6C55-82AB-5746-BABD-D254BE893418}.Debug|Any CPU.ActiveCfg = Debug|Win32
{AFBD6C55-82AB-5746-BABD-D254BE893418}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{AFBD6C55-82AB-5746-BABD-D254BE893418}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{AFBD6C55-82AB-5746-BABD-D254BE893418}.Debug|Win32.ActiveCfg = Debug|Win32
{AFBD6C55-82AB-5746-BABD-D254BE893418}.Debug|Win32.Build.0 = Debug|Win32
{AFBD6C55-82AB-5746-BABD-D254BE893418}.Debug|x64.ActiveCfg = Debug|x64
{AFBD6C55-82AB-5746-BABD-D254BE893418}.Debug|x64.Build.0 = Debug|x64
{AFBD6C55-82AB-5746-BABD-D254BE893418}.Debug|x86.ActiveCfg = Debug|Win32
{AFBD6C55-82AB-5746-BABD-D254BE893418}.Debug|x86.Build.0 = Debug|Win32
{AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|Any CPU.ActiveCfg = Release|Win32
{AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|Mixed Platforms.Build.0 = Release|Win32
{AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|Win32.ActiveCfg = Release|Win32
{AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|Win32.Build.0 = Release|Win32
{AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|x64.ActiveCfg = Release|x64
{AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|x64.Build.0 = Release|x64
{AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|x86.ActiveCfg = Release|Win32
{AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|x86.Build.0 = Release|Win32
{B477D6EA-E4AA-40B2-A129-48D2656DAAAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B477D6EA-E4AA-40B2-A129-48D2656DAAAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B477D6EA-E4AA-40B2-A129-48D2656DAAAF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{B477D6EA-E4AA-40B2-A129-48D2656DAAAF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{B477D6EA-E4AA-40B2-A129-48D2656DAAAF}.Debug|Win32.ActiveCfg = Debug|Any CPU
{B477D6EA-E4AA-40B2-A129-48D2656DAAAF}.Debug|x64.ActiveCfg = Debug|Any CPU
{B477D6EA-E4AA-40B2-A129-48D2656DAAAF}.Debug|x86.ActiveCfg = Debug|Any CPU
{B477D6EA-E4AA-40B2-A129-48D2656DAAAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B477D6EA-E4AA-40B2-A129-48D2656DAAAF}.Release|Any CPU.Build.0 = Release|Any CPU
{B477D6EA-E4AA-40B2-A129-48D2656DAAAF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{B477D6EA-E4AA-40B2-A129-48D2656DAAAF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{B477D6EA-E4AA-40B2-A129-48D2656DAAAF}.Release|Win32.ActiveCfg = Release|Any CPU
{B477D6EA-E4AA-40B2-A129-48D2656DAAAF}.Release|x64.ActiveCfg = Release|Any CPU
{B477D6EA-E4AA-40B2-A129-48D2656DAAAF}.Release|x86.ActiveCfg = Release|Any CPU
{83A2FE2B-A06C-4475-B9A2-9F2BE6072A62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{83A2FE2B-A06C-4475-B9A2-9F2BE6072A62}.Debug|Any CPU.Build.0 = Debug|Any CPU
{83A2FE2B-A06C-4475-B9A2-9F2BE6072A62}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{83A2FE2B-A06C-4475-B9A2-9F2BE6072A62}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{83A2FE2B-A06C-4475-B9A2-9F2BE6072A62}.Debug|Win32.ActiveCfg = Debug|Any CPU
{83A2FE2B-A06C-4475-B9A2-9F2BE6072A62}.Debug|x64.ActiveCfg = Debug|Any CPU
{83A2FE2B-A06C-4475-B9A2-9F2BE6072A62}.Debug|x86.ActiveCfg = Debug|Any CPU
{83A2FE2B-A06C-4475-B9A2-9F2BE6072A62}.Release|Any CPU.ActiveCfg = Release|Any CPU
{83A2FE2B-A06C-4475-B9A2-9F2BE6072A62}.Release|Any CPU.Build.0 = Release|Any CPU
{83A2FE2B-A06C-4475-B9A2-9F2BE6072A62}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{83A2FE2B-A06C-4475-B9A2-9F2BE6072A62}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{83A2FE2B-A06C-4475-B9A2-9F2BE6072A62}.Release|Win32.ActiveCfg = Release|Any CPU
{83A2FE2B-A06C-4475-B9A2-9F2BE6072A62}.Release|x64.ActiveCfg = Release|Any CPU
{83A2FE2B-A06C-4475-B9A2-9F2BE6072A62}.Release|x86.ActiveCfg = Release|Any CPU
{39D22122-C1DB-481C-A306-D746835E1701}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{39D22122-C1DB-481C-A306-D746835E1701}.Debug|Any CPU.Build.0 = Debug|Any CPU
{39D22122-C1DB-481C-A306-D746835E1701}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{39D22122-C1DB-481C-A306-D746835E1701}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{39D22122-C1DB-481C-A306-D746835E1701}.Debug|Win32.ActiveCfg = Debug|Any CPU
{39D22122-C1DB-481C-A306-D746835E1701}.Debug|x64.ActiveCfg = Debug|Any CPU
{39D22122-C1DB-481C-A306-D746835E1701}.Debug|x86.ActiveCfg = Debug|Any CPU
{39D22122-C1DB-481C-A306-D746835E1701}.Release|Any CPU.ActiveCfg = Release|Any CPU
{39D22122-C1DB-481C-A306-D746835E1701}.Release|Any CPU.Build.0 = Release|Any CPU
{39D22122-C1DB-481C-A306-D746835E1701}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{39D22122-C1DB-481C-A306-D746835E1701}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{39D22122-C1DB-481C-A306-D746835E1701}.Release|Win32.ActiveCfg = Release|Any CPU
{39D22122-C1DB-481C-A306-D746835E1701}.Release|x64.ActiveCfg = Release|Any CPU
{39D22122-C1DB-481C-A306-D746835E1701}.Release|x86.ActiveCfg = Release|Any CPU
{0E45ACDA-4EB0-4D9D-AD82-80A057E98899}.Debug|Any CPU.ActiveCfg = Debug|x86
{0E45ACDA-4EB0-4D9D-AD82-80A057E98899}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{0E45ACDA-4EB0-4D9D-AD82-80A057E98899}.Debug|Mixed Platforms.Build.0 = Debug|x86
{0E45ACDA-4EB0-4D9D-AD82-80A057E98899}.Debug|Win32.ActiveCfg = Debug|x86
{0E45ACDA-4EB0-4D9D-AD82-80A057E98899}.Debug|Win32.Build.0 = Debug|x86
{0E45ACDA-4EB0-4D9D-AD82-80A057E98899}.Debug|x64.ActiveCfg = Debug|x86
{0E45ACDA-4EB0-4D9D-AD82-80A057E98899}.Debug|x86.ActiveCfg = Debug|x86
{0E45ACDA-4EB0-4D9D-AD82-80A057E98899}.Debug|x86.Build.0 = Debug|x86
{0E45ACDA-4EB0-4D9D-AD82-80A057E98899}.Release|Any CPU.ActiveCfg = Release|x86
{0E45ACDA-4EB0-4D9D-AD82-80A057E98899}.Release|Mixed Platforms.ActiveCfg = Release|x86
{0E45ACDA-4EB0-4D9D-AD82-80A057E98899}.Release|Mixed Platforms.Build.0 = Release|x86
{0E45ACDA-4EB0-4D9D-AD82-80A057E98899}.Release|Win32.ActiveCfg = Release|x86
{0E45ACDA-4EB0-4D9D-AD82-80A057E98899}.Release|Win32.Build.0 = Release|x86
{0E45ACDA-4EB0-4D9D-AD82-80A057E98899}.Release|x64.ActiveCfg = Release|x86
{0E45ACDA-4EB0-4D9D-AD82-80A057E98899}.Release|x86.ActiveCfg = Release|x86
{0E45ACDA-4EB0-4D9D-AD82-80A057E98899}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{47B228CB-24FE-5250-B1FC-DFC81D3E69DF} = {2C4E4846-FF11-55AD-AFD1-BC1F3AF74724}
{499A5238-5AAC-5FD3-8902-819D787108A5} = {2C4E4846-FF11-55AD-AFD1-BC1F3AF74724}
{B477D6EA-E4AA-40B2-A129-48D2656DAAAF} = {06DF5654-1CEC-4113-88D8-6CBB985AB74D}
{83A2FE2B-A06C-4475-B9A2-9F2BE6072A62} = {06DF5654-1CEC-4113-88D8-6CBB985AB74D}
{39D22122-C1DB-481C-A306-D746835E1701} = {06DF5654-1CEC-4113-88D8-6CBB985AB74D}
{0E45ACDA-4EB0-4D9D-AD82-80A057E98899} = {06DF5654-1CEC-4113-88D8-6CBB985AB74D}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions src/AppcastTestHost/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
73 changes: 73 additions & 0 deletions src/AppcastTestHost/AppcastModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System;
using System.IO;
using Nancy;
using Nancy.Responses;

namespace AppcastTestHost
{
public class AppcastModule : NancyModule
{
private static string AppDirectory
{
get
{
return Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));
}
}

public AppcastModule()
{
Get["/{path}/{document}.{extension}"] = _p =>
{
try
{
return GetFile(Path.Combine(AppDirectory, _p.path), _p.document + "." + _p.extension);
}
catch (Exception ex)
{
Console.WriteLine("[500] " + ex.Message);
return new Response
{
StatusCode = HttpStatusCode.InternalServerError,
ReasonPhrase = ex.Message
};
}
};
}

private Response GetFile(string directory, string documentName)
{
// Set full path
var fullPath = Path.Combine(directory, documentName);

// Ensure file exists
if (!File.Exists(fullPath))
{
Console.WriteLine("[404] " + fullPath);
return new Response
{
StatusCode = HttpStatusCode.NotFound,
ReasonPhrase = "File not found: " + documentName
};
}

// Return file
Console.WriteLine("[200] " + fullPath);
//return new StreamResponse(() => GenerateStreamFromString(File.ReadAllText(fullPath)), MimeTypes.GetMimeType(fullPath)).AsAttachment(documentName);

var file = new FileStream(fullPath, FileMode.Open);

return new StreamResponse(() => file, MimeTypes.GetMimeType(fullPath));
}

private Stream GenerateStreamFromString(string s)
{
var stream = new MemoryStream();
var writer = new StreamWriter(stream);
writer.Write(s);
writer.Flush();
stream.Position = 0;
return stream;
}
}
}
Loading