Files
Oogynize/AddIns/AddIn.Common/CommonValidations.cs

38 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Foo.AddIn.Common
{
public static class Validate
{
/// <summary>
/// Validate ArtifactLocation * We could later do much more work here *
/// </summary>
/// <returns></returns>
public static bool IsValidArtifactLocation(string strArtifactLocation, ref FuncRetVal retVal)
{
// All URLs should contain that character (Files aren't allowed to contain it)
bool bIsUrl = strArtifactLocation.Contains('/');
if (String.IsNullOrEmpty(strArtifactLocation))
{
retVal.Type = FuncRetValEnum.ParameterInvalid;
return false;
}
else if (!bIsUrl && !File.Exists(strArtifactLocation))
{
// Check File existence (if it doesn't return false)
return false;
}
else
{
return true;
}
}
}
}