Пример #1
0
        public IEnumerator Read()
        {
            // Given an existing file in a relative path.
            Assert.IsTrue(defaultFileSystem.Exists(RelativeFilePath));

            // When reading the file from the relative path.
            byte[] fileData = defaultFileSystem.Read(RelativeFilePath);
            string message  = Encoding.Default.GetString(fileData);

            // Then assert that the file content was retrieved.
            Assert.That(fileData != null && fileData.Length > 0);
            Assert.IsFalse(string.IsNullOrEmpty(message));
            yield break;
        }
Пример #2
0
        /// <summary>
        /// Returns true if given <paramref name="filePath"/> contains the name of an existing file under the StreamingAssets or platform persistent data folder; otherwise, false.
        /// </summary>
        /// <remarks><paramref name="filePath"/> must be relative to the StreamingAssets or the platform persistent data folder.</remarks>
        public static bool Exists(string filePath)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                throw new ArgumentException("Invalid 'filePath'");
            }

            if (Path.IsPathRooted(filePath))
            {
                throw new ArgumentException($"Method only accepts relative paths.\n'filePath': {filePath}");
            }

            return(platformFileSystem.Exists(filePath));
        }