Kizspy | Question: 32
(Choose 1 answer)
Which code demonstrates the use of FileStream for reading a file?
A. using (FileStream fs = new FileStream("example.txt", FileMode.Open))
{
byte[] bytes new byte[fs.Length];
fs.Read(bytes, 0, (int)fs.Length);
}
B. using (FileStream fs = new FileStream("example.txt", FileMode.Create))
{
byte[] bytes = new byte[fs.Length];
fs.Read(bytes, 0, (int)fs.Length);
}
C. using (FileStream fs = new FileStream("example.txt", FileMode.OpenOrCreate))
}
byte[] bytes = new byte[fs.Length];
fs.Write(bytes, 0, (int)fs.Length);
}
D. using (FileStream fs = new FileStream("example.txt", FileMode.CreateNew))
{
byte[] bytes = new byte[fs.Length];
fs.Seek(0, SeekOrigin.Begin);
}