コード例 #1
0
        /// <summary>
        /// Opens a file and returns its contents as a <see cref="Stream" />.
        /// </summary>
        /// <param name="path">The path to the file to open.</param>
        /// <param name="mode">The file mode (read, write, append).</param>
        /// <returns>
        /// The stream specified by path.
        /// </returns>
        public Stream StreamFromFile(string path, Common.FileMode mode)
        {
            Stream file;
            string pathCpy = path.ToLower();

            if (pathCpy.StartsWith("assets/") || pathCpy.StartsWith("assets\\"))
            {
                path = path.Substring("assets/".Length);
                file = _androidContext.Assets.Open(path);
            }
            else
            {
                file = _androidContext.OpenFileInput(path);
            }

            if (file == null)
            {
                throw new FileNotFoundException(path);
            }

            return(file);
        }
コード例 #2
0
 /// <summary>
 /// Opens a file and returns its contents as a <see cref="Stream" />.
 /// </summary>
 /// <param name="path">The path to the file to open.</param>
 /// <param name="mode">The file mode (read, write, append).</param>
 /// <returns>
 /// The stream specified by path.
 /// </returns>
 public Stream StreamFromFile(string path, Common.FileMode mode)
 {
     return(new FileStream(path, (System.IO.FileMode)mode));
 }
コード例 #3
0
 /// <summary>
 /// Opens a file and returns its contents as a <see cref="Stream" />.
 /// </summary>
 /// <param name="path">The path to the file to open.</param>
 /// <param name="mode">The mode.</param>
 /// <returns>
 /// A stream
 /// </returns>
 /// <exception>
 /// Exceptions thrown by this method depend on the underlying
 /// platform dependent implementation.
 /// </exception>
 public static Stream StreamFromFile(string path, Common.FileMode mode)
 {
     return(IOImp.StreamFromFile(path, mode));
 }