Ejemplo n.º 1
0
        public bool Equals(FileToken objFileToken)
        {
            if (objFileToken == null)
            {
                return(false);
            }

            return((RelativePath == objFileToken.RelativePath) && (Hash == objFileToken.Hash));
        }
Ejemplo n.º 2
0
        public override bool Equals(object objValue)
        {
            if (objValue == null)
            {
                return(false);
            }

            FileToken objFileToken = objValue as FileToken;

            return(Equals(objFileToken));
        }
Ejemplo n.º 3
0
        public static FileToken Load(string strFilePath, string strRelativePath)
        {
            if (strFilePath == null)
            {
                throw new ArgumentNullException("strFilePath", "A valid non-null string is required.");
            }
            if (FileManager.Exists(strFilePath) == false)
            {
                throw new FileNotFoundException("Unable to generate FileToken because the file does not exist.", strFilePath);
            }

            FileToken objFileToken = null;

            if (FileManager.Exists(strFilePath) == true)
            {
                string strHash = string.Empty;

                FileInfo objFileInfo = new FileInfo(strFilePath);
                try
                {
                    using (Stream objFileSteam = objFileInfo.OpenRead())
                    {
                        HashBase.Default.ComputeHash(objFileSteam, out strHash);
                    }

                    FileVersionInfo objFileVersionInfo = FileVersionInfo.GetVersionInfo(strFilePath);
                    VersionToken    objVersionToken    = new VersionToken(objFileVersionInfo.FileBuildPart, objFileVersionInfo.FileMajorPart, objFileVersionInfo.FileMinorPart, 0);

                    string strRelativeFileName = Path.Combine(strRelativePath, objFileInfo.Name);
                    objFileToken = new FileToken(strFilePath, strRelativeFileName, strHash, objFileInfo.Length, objVersionToken);
                }
                catch
                {}
            }

            return(objFileToken);
        }
Ejemplo n.º 4
0
 public static FileToken Load(string strFilePath)
 {
     return(FileToken.Load(strFilePath, string.Empty));
 }