I have code that contained two using statements. The Inner using statement is reading a response stream and the outer is opening a file to write the response too.
The following code works fine (sfd is a SaveFileDialog):
using (Stream fs = sfd.OpenFile())
using (var responseStream = response.GetResponseStream())
{
// Work
}
The following does not work
using (Stream fs = sfd.OpenFile())
{
using (var responseStream = response.GetResponseStream())
{
// Work
}
}
The only difference is that I inputted the curly braces to make the code more readable, but that breaks the code. Any ideas as to why? It does not quite make sense yet.