dimanche 16 juin 2019

Conditional 'using'

I have the following code that does some conversion from one file to a memory stream which I then write to disk. All is working fine, however I now want to still always open file_1 for reading, but either open memory_stream or file_2 for writing based on user preference.

How can I get a conditional statement working in this situation given the braces will clash.

Thanks in advance for any help.

public static void ProcessFile()
{
   try
   {         
      using (Open file_1 for reading)
      using (Open memory_stream for writing)
      {
         ...

Aucun commentaire:

Enregistrer un commentaire