If simple:

wClient.DownloadFile(url, path); 

Saves the file, it is not empty. And if so:

 wClient.DownloadFile(url, path); using (FileStream file = new FileStream(path, FileMode.Truncate)) { }; 

That file creates, but the file is always empty. Both actions are in Task, Task is called by pressing the button.

    1 answer 1

    And what is the actual question? FileMode.Truncate indicates that you need to open an existing file and discard its contents, that is, the file length becomes 0 bytes. That is, first you download the file, and then immediately delete it.

    • Thanks, that might be the answer. By the way, I need to delete the file if it is empty code inside the uses. What should I write then FileMode? - Egor Randomize
    • FileMode.Append, thanks - Egor Randomize