From 0ca86ba15108fe3c8e83356288e15bfa151ee162 Mon Sep 17 00:00:00 2001 From: ivandrofly Date: Thu, 4 Jun 2015 15:34:49 +0100 Subject: [PATCH] Added: 2 methods to check if path is file|directory (src/Core/FileUtil) --- src/Core/FileUtil.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Core/FileUtil.cs b/src/Core/FileUtil.cs index 8491d5518..91ea9b4f9 100644 --- a/src/Core/FileUtil.cs +++ b/src/Core/FileUtil.cs @@ -316,5 +316,18 @@ namespace Nikse.SubtitleEdit.Core return true; } + public static bool IsFile(string path) + { + if (!Path.IsPathRooted(path)) + return false; + return ((File.GetAttributes(path) & FileAttributes.Directory) != FileAttributes.Directory); + } + + public static bool IsDirectory(string path) + { + if (!Path.IsPathRooted(path)) + return false; + return ((File.GetAttributes(path) & FileAttributes.Directory) == FileAttributes.Directory); + } } }