Example #1
0
        public static bool fileExists(string path, int timeout = 10000)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(false);
            }
            bool found = ShortTask.Execute <bool>(timeout, false, () =>
            {
                bool exists = false;
                if (path.IndexOfAny(new char[] { '?', '*' }) >= 0)
                {
                    string folderPath = Path.GetDirectoryName(path);
                    string filePath   = Path.GetFileName(path);
                    string[] files    = null;
                    try
                    {
                        if (Util.directoryExists(folderPath))
                        {
                            files = Directory.GetFiles(folderPath, filePath, SearchOption.TopDirectoryOnly);
                        }
                    }
                    catch (Exception ex) { }
                    exists = (files != null && files.Length != 0);
                }
                else
                {
                    exists = File.Exists(path);
                }
                return(exists);
            });

            return(found);
        }
Example #2
0
        public static bool directoryExists(string path, int timeout = 10000)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(false);
            }
            bool found = ShortTask.Execute <bool>(timeout, false, () =>
            {
                return(Directory.Exists(path));
            });

            return(found);
        }