示例#1
0
        /// <summary>
        ///     Returns files in a specfied directory
        /// </summary>
        /// <param name="foldername"></param>
        /// <param name="searchPattern"></param>
        /// <returns></returns>
        public string[] GetFiles(string foldername, string searchPattern)
        {
            bool folderExists = DirectoryExists(foldername);

            if (!folderExists)
            {
                throw new InvalidFilePathException(foldername);
            }

            List <string> files = new List <string>();

            if (Directory.Exists(foldername))
            {
                Logger.Log(LogType.Log, foldername + " Found in File System.", 5);
                files = Directory.GetFiles(foldername, searchPattern).ToList();
            }

            if (ManifestReader.DirectoryExists(foldername))
            {
                Logger.Log(LogType.Log, foldername + " Found in Assembly Manifest.", 5);
                files.AddRange(ManifestReader.GetFiles(foldername, searchPattern /*.Replace("*", "")*/));
            }

            return(files.ToArray());
        }
示例#2
0
        /// <summary>
        ///     Returns true if the file exists on either the disk or in the assembly
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public bool FileExists(string filename)
        {
            bool isFile     = EnableFileSystem && File.Exists(filename);
            bool isManifest = EnableManifest && ManifestReader.Exists(filename);

            return(isFile || isManifest);
        }
示例#3
0
        /// <summary>
        ///     Returns true if the folder exists on either the disk or in the assembly
        /// </summary>
        /// <param name="foldername"></param>
        /// <returns></returns>
        public bool DirectoryExists(string foldername)
        {
            bool isFile     = EnableFileSystem && Directory.Exists(foldername);
            bool isManifest = EnableManifest && ManifestReader.DirectoryExists(foldername);

            return(isFile || isManifest);
        }
示例#4
0
        /// <summary>
        ///     Returns the byte stream of the file specified
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public Stream GetStream(string filename)
        {
            if (EnableFileSystem && File.Exists(filename))
            {
                Logger.Log(LogType.Log, filename + " Found in File System.", 5);
                return(File.OpenRead(filename));
            }

            if (EnableManifest && ManifestReader.Exists(filename))
            {
                Logger.Log(LogType.Log, filename + " Found in Assembly Manifest.", 5);
                return(ManifestReader.GetStreamByPath(filename));
            }

            throw new InvalidFilePathException(filename);
        }
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="filePath">The File that was not found</param>
 public InvalidFilePathException(string filePath) : this(filePath, null)
 {
     Logger.Log(LogType.Error, "Files:", 10);
     ManifestReader.ListAllFiles();
 }