Hashset for MD5 Checksum of Files in Google Drive

寵の児 提交于 2019-12-11 06:06:32

问题


I here am able to generate the MD5 hash of the files in the Google Drive. The next step is I want to like compare those hashes and should there be an identical hash , the program will prevent the application from uploading that file due to the same hash.

I tried declaring a hashset and calling the MD5checksum in the parameters and declaring a function to generate the hash but neither both these are working,

public static List<GoogleDriveFiles> GetDriveFiles()
    {
        DriveService service = GetService();

        // define parameters of request.
        FilesResource.ListRequest FileListRequest = service.Files.List();

        //listRequest.PageSize = 10;
        //listRequest.PageToken = 10;
        FileListRequest.Fields = "nextPageToken, files(id, name, size, createdTime, md5Checksum)";

        //get file list.
        IList<Google.Apis.Drive.v3.Data.File> files = FileListRequest.Execute().Files;
        List<GoogleDriveFiles> FileList = new List<GoogleDriveFiles>();

        //get hash

        if (files != null && files.Count > 0)
        {
            foreach (var file in files)
            {
                GoogleDriveFiles File = new GoogleDriveFiles
                {
                    Id = file.Id,
                    Name = file.Name,
                    Size = file.Size,
                    CreatedTime = file.CreatedTime,
                    MD5hash = file.Md5Checksum,

            };
                FileList.Add(File);

            }
        }
        return FileList;

    }

How can I generate like a hashset for those hash values that have been obtained or is there another practical way to store and compare those MD5 hash?

来源:https://stackoverflow.com/questions/57535636/hashset-for-md5-checksum-of-files-in-google-drive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!