root / trunk / Pithos.Client.WPF / Preferences / FileExistsRule.cs @ 3ddbb7b8
History | View | Annotate | Download (758 Bytes)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Globalization; |
4 |
using System.IO; |
5 |
using System.Linq; |
6 |
using System.Text; |
7 |
using System.Windows.Controls; |
8 |
|
9 |
namespace Pithos.Client.WPF.Preferences |
10 |
{ |
11 |
public class DirectoryExistsRule : ValidationRule |
12 |
{ |
13 |
public override ValidationResult Validate(object value, CultureInfo cultureInfo) |
14 |
{ |
15 |
|
16 |
if (!(value is string)) |
17 |
return new ValidationResult(false,"Value is not a path"); |
18 |
|
19 |
if (Directory.Exists(value as string)) |
20 |
return ValidationResult.ValidResult; |
21 |
|
22 |
return new ValidationResult(false,String.Format("Path {0} does not exist or is not a directory",value)); |
23 |
|
24 |
} |
25 |
} |
26 |
|
27 |
|
28 |
} |