-
Notifications
You must be signed in to change notification settings - Fork 62
/
DSHelper.cs
42 lines (35 loc) · 1.25 KB
/
DSHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// <copyright file="DSHelper.cs" company="DocuSign">
// Copyright (c) DocuSign. All rights reserved.
// </copyright>
namespace DocuSign.CodeExamples.Common
{
using System.IO;
using System.Runtime.InteropServices;
internal class DsHelper
{
internal static string PrepareFullPrivateKeyFilePath(string fileName)
{
const string defaultRsaPrivateKeyFileName = "private.key";
var fileNameOnly = Path.GetFileName(fileName);
if (string.IsNullOrEmpty(fileNameOnly))
{
fileNameOnly = defaultRsaPrivateKeyFileName;
}
var filePath = Path.GetDirectoryName(fileName);
if (string.IsNullOrEmpty(filePath))
{
filePath = Directory.GetCurrentDirectory();
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) && Directory.GetCurrentDirectory().Contains("bin"))
{
fileNameOnly = defaultRsaPrivateKeyFileName;
filePath = Path.GetFullPath(filePath);
}
return Path.Combine(filePath, fileNameOnly);
}
internal static byte[] ReadFileContent(string path)
{
return File.ReadAllBytes(path);
}
}
}