Show / Hide Table of Contents

    How to get partial content from a section

    To get a partial content from a section start and end value and the section is needed.

    Note

    There is only an async method available

    Get Stream

    public static async Task<Stream> GetPartialStreamFromSection(Section section, int startByte, int endByte)
    {
        DeserializedHttpResponse<Stream> partialContent = section.DownloadContentAsync(startByte, endByte).Result;
    
        if (partialContent.IsSuccessStatusCode)
        {
            return partialContent.Content;
        }
        else
        {
            return null;
        }
    }
    

    Save File

    public static async Task SavePartialStreamFromSection(Section section, int startByte, int endByte, string fileDestination)
    {
        DeserializedHttpResponse<Stream> partialContent = section.DownloadContentAsync(startByte, endByte).Result;
    
        if (partialContent.IsSuccessStatusCode)
        {
            Stream contentStream = partialContent.Content;
    
            using (var outputStream = new FileStream(fileDestination, FileMode.Append, FileAccess.Write))
            {
                contentStream.CopyTo(outputStream);
            }
        }
        else
        {
            throw new Exception("Failure");
        }
    }
    
    About Us Contact Imprint Terms Data privacy
    © 2024 DocuWare Corporation powered by DocFX Back to top