Which code should you insert at line 12?

You have the following code. (Line numbers are included for reference only).


You need to complete the WriteTextAsync method. The solution must ensure that the code is not blocked while the file is being written. Which code should you insert at line 12?


A. Option A
B. Option B
C. Option C
D. Option D

microsoft-exams

2 thoughts on “Which code should you insert at line 12?

  1. static void Main(string[] args)
    {
    ProcessFileWrite();
    }

    public static async void ProcessFileWrite() {

    string filePath = @”C:\\Rfile.txt”;
    string txt = “Bismillahirrahmanirrahim”;
    await WriteTextToFileAsync(filePath, txt);
    }

    public static async Task WriteTextToFileAsync(string filePath,string txt) {
    byte[] encodedText = Encoding.Unicode.GetBytes(txt);
    using (FileStream fs = new FileStream(filePath,FileMode.Append,FileAccess.Write,FileShare.None,bufferSize : 4096 ,useAsync : true)) {
    await fs.WriteAsync(encodedText, 0, encodedText.Length);
    }
    }

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.