locked
Download file RRS feed

  • Question

  • User-284642143 posted
    I have a class library with some code to download a file (same code works on a page). When I put this into a class library, import all references, I get file not found in Edge even though I can get to the file when I debug it and network failed in chrome.

    I can post the code but is there something I'm missing before I do when I use a response object to download a file when the code is in a library?
    Wednesday, January 3, 2018 8:55 AM

Answers

  • User753101303 posted

    Hi,

    You are using TransmitFile? Could it be that the file is really not found? IMO it's best to always start from the error message rather than from the code. Here I would make 100% sure the file I'm trying to use does exists possibly by showing temporarily what is returned by https://msdn.microsoft.com/en-us/library/system.io.file.exists%28v=vs.110%29.aspx

    EssCee

    I can get to the file when I debug it and network failed in chrome

    This is a bit confusing.Could it be a confusion between client side and server side files ???

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 3, 2018 9:03 AM

All replies

  • User753101303 posted

    Hi,

    You are using TransmitFile? Could it be that the file is really not found? IMO it's best to always start from the error message rather than from the code. Here I would make 100% sure the file I'm trying to use does exists possibly by showing temporarily what is returned by https://msdn.microsoft.com/en-us/library/system.io.file.exists%28v=vs.110%29.aspx

    EssCee

    I can get to the file when I debug it and network failed in chrome

    This is a bit confusing.Could it be a confusion between client side and server side files ???

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 3, 2018 9:03 AM
  • User1738843376 posted

    use the response object using its namespace:

    HttpContext.Current.Response

    Wednesday, January 3, 2018 4:20 PM
  • User-832373396 posted

    Hi EssCee,

    When I put this into a class library,

    Sir, they are the different ways to get file path <g class="gr_ gr_24 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" id="24" data-gr-id="24">at </g><g class="gr_ gr_24 gr-alert gr_gramm gr_inline_cards gr_disable_anim_appear Style multiReplace" id="24" data-gr-id="24"> a</g> class library and a startup web project.

    So, commonly, It doesn't recommend putting the resource file and get file path code put into a class library;

    With regards, Angelina Jolie

    Thursday, January 4, 2018 7:31 AM