mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
* Pattern match to IConfigurationRoot and reload. * Update documentation. * AgentHubConnection and logger updates. Trying to deprecate static Logger. * Update build.yml * Update build.yml
43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Remotely.Shared.Extensions
|
|
{
|
|
public static class StringExtensions
|
|
{
|
|
public static string SanitizeFileName(this string fileName)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(fileName))
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
var invalidChars = Path.GetInvalidFileNameChars();
|
|
var validChars = fileName
|
|
.Where(x => !invalidChars.Contains(x))
|
|
.ToArray();
|
|
|
|
return new string(validChars);
|
|
}
|
|
|
|
public static string SanitizeFileSystemPath(this string path)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(path))
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
var invalidChars = Path.GetInvalidPathChars();
|
|
var validChars = path
|
|
.Where(x => !invalidChars.Contains(x))
|
|
.ToArray();
|
|
|
|
return new string(validChars);
|
|
}
|
|
}
|
|
}
|