internal static bool CheckWriteToDir()

in SimpleDUTRemote/HelperFunctions/ReadWriteChecks.cs [58:84]


        internal static bool CheckWriteToDir(string path)
        {
            try
            {
                if (!Directory.Exists(path))
                {
                    throw new FileNotFoundException($"Target directory {path} doesn't exist.");
                }

                // can we write a file here?
                using (var fstream = File.Create(
                    Path.Combine(path, Path.GetRandomFileName()),
                    1024,
                    FileOptions.DeleteOnClose))
                {
                    return true;
                }
            }
            catch (Exception e)
            {
                if (e is IOException || e is UnauthorizedAccessException)
                    return false;
                else
                    throw;
            }

        }