Moved duplicated NormalizePath method to PathExtentions

This commit is contained in:
kay.one 2011-11-20 16:35:29 -08:00
commit 6778a6ed99
9 changed files with 54 additions and 60 deletions

View file

@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
namespace NzbDrone.Common
{
@ -22,6 +23,22 @@ namespace NzbDrone.Common
private const string UPDATE_CLIENT_EXE = "nzbdrone.update.exe";
private const string UPDATE_CLIENT_FOLDER_NAME = "NzbDrone.Update\\";
public static string NormalizePath(this string path)
{
if (String.IsNullOrWhiteSpace(path))
throw new ArgumentException("Path can not be null or empty");
var info = new FileInfo(path);
if (info.FullName.StartsWith(@"\\")) //UNC
{
return info.FullName.TrimEnd('/', '\\', ' ');
}
return info.FullName.Trim('/', '\\', ' ');
}
public static string GetIISFolder(this EnviromentProvider enviromentProvider)
{
return Path.Combine(enviromentProvider.ApplicationPath, IIS_FOLDER);