How to correctly check FileStreamWriter is in use?

33 Views Asked by At

I am using a System::IO::StreamWriter. My intention is to check if the file in use is open, and close it.

What is the correct way of checking if the file is in use. I keep getting System.NullReferenceException with the code below.

if (filewr2->BaseStream != nullptr)
{
    filewr2->Close();
    filewr2 = nullptr;
}
0

There are 0 best solutions below