What does the HttpResponse.WriteFile parameter of the bool readIntoMemory method do?

What does the HttpResponse.WriteFile parameter of the bool readIntoMemory method do?

The MSDN documentation is very useless in this regard, since I came across this method and am not quite sure why I want to do this or not to do it.

Note. Whether someone should answer “it’s good that he reads the file into memory”, without any further explanation, will be rejected.

+3
source share
3 answers

Looking for a reflector, it seems that the file should be buffered in memory before being written to the response.

FileStream, , boolean , , WriteBytes.

, WriteFile.

, HttpWriter. , WriteStreamAsText.

+2

- , , , / - , -, , bool ReadAllBytes .

+6

- .

true readIntoMemory, , , WriteFile. , false, ( , ). , ( HttpWriter.WriteFile). (, , ), .

:

protected void Page_Load(object sender, EventArgs e)
{
    Response.WriteFile(@"C:\myFile", false);
    System.IO.File.Move(@"C:\myFile", "C:\myFile2");
    Response.End();
}

, , - Response.End. readIntoMemory true .

+4

Source: https://habr.com/ru/post/1759973/


All Articles