You need to return the contents of an isolated storage file as a string. The file is machine-scoped and is named Settings.dat. Which code segment should you use?

You need to return the contents of an isolated storage file as a string. The file is machine-scoped
and is named Settings.dat. Which code segment should you use?

A. IsolatedStorageFileStream^ isoStream;isoStream = gcnew IsolatedStorageFileStream(
“Settings.dat”, FileMode::Open); String^ result = (gcnew StreamReader(isoStream))-
>ReadToEnd();
B. IsolatedStorageFile^ isoFile;isoFile = IsolatedStorageFile::GetMachineStoreForAssembly();
IsolatedStorageFileStream^ isoStream;isoStream = gcnew IsolatedStorageFileStream(
“Settings.dat”, FileMode::Open, isoFile); String^ result = (gcnew StreamReader(isoStream))-
>ReadToEnd();
C. IsolatedStorageFileStream^ isoStream;isoStream = gcnew IsolatedStorageFileStream(
“Settings.dat”, FileMode::Open);String^ result = isoStream->ToString();
D. IsolatedStorageFile^ isoFile;isoFile = IsolatedStorageFile::GetMachineStoreForAssemblly();
IsolatedStorageFileStream^ isoStream;isoStream = gcnew IsolatedStorageFileStream(
“Settings.dat”, FileMode::Open, isoFile); String^ result = isoStream->ToString();

Answer: B 

No comments:

Post a Comment