...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
/* IMPORTANT! ** For using this example you need to uncheck the "Allow generation of asynchronous operation" option in advanced Service Reference settings*/ using System; using System.Data; using System.IO; using YourServiceReferenceHere; namespace ConsoleApp2 { class Program { public static SecurityToken GetAuth() { SecurityToken securityToken = new SecurityToken() { Username = "Student Portal", UserId = -2, DashboardAdmin = true }; return securityToken; } static void Main(string[] args) { GetFileFromDocumentRequirementFileAttachmentById(/*documentRequirementIdFileAttachmentId*/, /*Target folder path*/); } static void GetFileFromDocumentRequirementFileAttachmentById(int documentRequirementIdFileAttachmentId, string targetFolder) { using (var client = new RegentEnterpriseServiceClient()) { var request = new GetDocumentRequirementFileAttachmentRequest { SecurityToken = GetAuth(), Id = documentRequirementIdFileAttachmentId, IdSpecified = true, }; var record = client.getDocumentRequirementFileAttachment(request).Record; if (record.StoredFile.Length > 0) { File.WriteAllBytes(Path.Combine(targetFolder, record.FileName), record.StoredFile); } } } } } |
...