Exemplo n.º 1
0
        public bool IsFileLibrary()
        {
            bool ret = false;

            FileStream fs;
            Type       formatType;
            Xsf        checkFile;
            ArrayList  libPathArray;

            string libDirectory = Path.GetDirectoryName(Path.GetFullPath(this.filePath));

            foreach (string f in Directory.GetFiles(libDirectory))
            {
                try
                {
                    fs         = File.OpenRead(f);
                    formatType = FormatUtil.getObjectType(fs);

                    if (formatType == this.GetType())
                    {
                        fs.Seek(0, SeekOrigin.Begin);
                        checkFile = new Xsf();
                        checkFile.Initialize(fs, f);
                        libPathArray = new ArrayList(checkFile.GetLibPathArray());

                        if (libPathArray.Contains(this.filePath.ToUpper()))
                        {
                            ret = true;
                            fs.Close();
                            fs.Dispose();
                            break;
                        }
                    }
                    fs.Close();
                    fs.Dispose();
                }
                catch (Exception)
                {
                    // Do nothing for now, if the file cannot be read than it cannot need a lib
                }
            }

            return(ret);
        }