Beispiel #1
0
        string CalculateSHA512(XFileInfo xFile)
        {
            string filename = xFile.Path + xFile.Name;

            using (var sha512 = SHA512.Create())
            {
                using (var stream = File.OpenRead(filename))
                {
                    var hash = sha512.ComputeHash(stream);
                    LogTextBox.Text += "Done!\n";
                    return(BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant());
                }
            }
        }
Beispiel #2
0
        string CalculateMD5(XFileInfo xFile)
        {
            string filename = xFile.Path + xFile.Name;

            LogTextBox.Text += "Calculating MD5 of file " + filename + "...\n";
            using (var md5 = MD5.Create())
            {
                using (var stream = File.OpenRead(filename))
                {
                    var hash = md5.ComputeHash(stream);
                    LogTextBox.Text += "Done!\n";
                    return(BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant());
                }
            }
        }
Beispiel #3
0
        string GetAttributesFromFile(XFileInfo xFile)
        {
            string         filename      = xFile.Path + xFile.Name;
            string         AttributeList = "";
            FileInfo       f             = new FileInfo(filename);
            FileAttributes fAttr         = f.Attributes;

            if ((fAttr & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
            {
                AttributeList += "ReadOnly ";
            }
            if ((fAttr & FileAttributes.Hidden) == FileAttributes.Hidden)
            {
                AttributeList += "Hidden ";
            }
            if ((fAttr & FileAttributes.System) == FileAttributes.System)
            {
                AttributeList += "System ";
            }

            return(AttributeList);
        }
Beispiel #4
0
        int OpenFolder()
        {
            Files.Clear();
            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();

            folderBrowserDialog.ShowDialog();
            string Path = folderBrowserDialog.SelectedPath;

            ToolStripFolderPathText.Text = "Directory " + Path;

            string[] files = System.IO.Directory.GetFiles(Path, "*.*", SearchOption.AllDirectories);
            LogTextBox.Text += "Working in directory at " + Path + "\n------------------------\n";
            foreach (string filename in files)
            {
                XFileInfo fTemp = new XFileInfo();
                fTemp.Path = Path;
                fTemp.Name = filename.Remove(0, Path.Length);
                Files.Add(fTemp);
                LogTextBox.Text += "Found a file at " + fTemp.Path + "\n";
            }
            return(files.Count());
        }