public static string FileToJSON(string selectedFile) { string fileName = Base64.Base64Encode(selectedFile); string path = "C:/idh14Client/" + selectedFile; Byte[] bytes = File.ReadAllBytes(path); String content = Convert.ToBase64String(bytes); string checksum = Checksums.GetSha1Hash(path); string originalchecksum = "test"; string str = "PUT {"; str += " 'filename': '" + fileName + "',"; str += " 'content': '" + content + "',"; str += " 'checksum': '" + checksum + "',"; str += " 'originalchecksum': '" + originalchecksum + "'"; str += "}"; return(str); }
public static List <FileHandler> GetFiles() { var model = new List <FileHandler>(); // Set c so folder can be checked by client DirectoryInfo c = new DirectoryInfo(@"C:\idh14Client\"); //Get all files FileInfo[] Files2 = c.GetFiles("*.*"); foreach (FileInfo file in Files2) { FileHandler tempFile = new FileHandler(); tempFile.FileName = file.Name; string filePath = c + file.Name; //Show SHA1 hash of current version of the file tempFile.Checksum = Checksums.GetSha1Hash(filePath); model.Add(tempFile); } return(model); }