问题
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