Download from html pdf/word/jpeg pics or any hyperlink attachment. using c#

nellie 126 Reputation points
2021-03-18T22:13:54.683+00:00

Hi

I have an html where there are hyperlinks to pdf' / word docs /jpeg ... I want to download them locally and have all the hyperlinks adjusted to point locally.
How can I do this ?

cheers

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,280 questions
0 comments No comments
{count} votes

Accepted answer
  1. Daniel Zhang-MSFT 9,636 Reputation points
    2021-03-19T06:25:22.89+00:00

    Hi nellie-2760,
    You can try to add the attribute 'download' to your links.

    <a href="/test.pdf" download>  
    

    And if you want to link to local files, you need to use the file:/// protocol.
    But many browsers such as Firefox and Chrome refuses to cross from the http(s) protocol to the file protocol to prevent malicious behaviour.
    More details please refer to doppelgreener's answer.
    Best Regards,
    Daniel Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.