Answer the question
In order to leave comments, you need to log in
Why is a large piece of code ignored after executing httpClient.GetStreamAsync()?
Good afternoon. I practically wrote the entire code for adding a product to the Vkontakte group using the API and ran into a new problem. I have a fragment in my code that is responsible for downloading an image via a direct link:
...
HttpClient httpClient = new HttpClient();
Stream stream = await httpClient.GetStreamAsync(dataExcelTabel[i].photo2);
FileStream file = File.OpenWrite(PathForSavePhotos + "/" + dataExcelTabel[i].codeProduct + "." + splitFileName[splitFileName.Length - 1]);
dataExcelTabel[i].pathPhotoSave = file.Name;
await stream.CopyToAsync(file);
//Закрываем потоки
stream.Close();
file.Close();
...
Stream stream = await httpClient.GetStreamAsync(dataExcelTabel[i].photo2);
the compiler simply ignores the huge piece of code and jumps to the next method without executing the current one. Even in turn-by-turn mode flies by. What am I missing? Tell me please
Answer the question
In order to leave comments, you need to log in
I would recommend wrapping your piece of code in a try/catch (Exception e) first, put a breakpoint on the next line after the problematic method, and in the catch body. Either there or there should work, so you narrow down the circle of suspects :)
in the code, there is a complete exit from the UploadPhotos () method, although I still have a decent part of the code there that should be executed. The jump occurs in both turn-based and normal mode.
File.OpenWrite(PathForSavePhotos + "/" + dataExcelTabel[i].codeProduct + "." + splitFileName[splitFileName.Length - 1]);
.Close();
Use using Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question