IsolatedStorageFileStream::Handle Property
Gets the file handle for the file that the current IsolatedStorageFileStream object encapsulates. Accessing this property is not permitted on an IsolatedStorageFileStream object, and throws an IsolatedStorageException.
Assembly: mscorlib (in mscorlib.dll)
public: [ObsoleteAttribute("This property has been deprecated. Please use IsolatedStorageFileStream's SafeFileHandle property instead. http://go.microsoft.com/fwlink/?linkid=14202")] property IntPtr Handle { [SecurityCriticalAttribute] [SecurityPermissionAttribute(SecurityAction::InheritanceDemand, Flags = SecurityPermissionFlag::UnmanagedCode)] virtual IntPtr get() override; }
Property Value
Type: System::IntPtrThe file handle for the file that the current IsolatedStorageFileStream object encapsulates.
| Exception | Condition |
|---|---|
| IsolatedStorageException | The Handle property always generates this exception. |
The following code example demonstrates the Handle property.
[SecurityPermissionAttribute(SecurityAction::Demand, Flags=SecurityPermissionFlag::UnmanagedCode)] bool GetPrefsForUser() { try { // Retrieve an IsolatedStorageFile for the current Domain and Assembly. IsolatedStorageFile^ isoFile = IsolatedStorageFile::GetStore( static_cast<IsolatedStorageScope>(IsolatedStorageScope::User | IsolatedStorageScope::Assembly | IsolatedStorageScope::Domain), (Type^)nullptr, nullptr ); IsolatedStorageFileStream^ isoStream = gcnew IsolatedStorageFileStream( this->userName,FileMode::Open,FileAccess::ReadWrite,isoFile ); // farThe code executes to this point only if a file corresponding to the username exists. // Though you can perform operations on the stream, you cannot get a handle to the file. try { IntPtr aFileHandle = isoStream->Handle; Console::WriteLine( "A pointer to a file handle has been obtained. {0} {1}", aFileHandle, aFileHandle.GetHashCode() ); } catch ( Exception^ e ) { // Handle the exception. Console::WriteLine( "Expected exception" ); Console::WriteLine( e->ToString() ); } StreamReader^ reader = gcnew StreamReader( isoStream ); // Read the data. this->NewsUrl = reader->ReadLine(); this->SportsUrl = reader->ReadLine(); reader->Close(); isoFile->Close(); isoStream->Close(); return false; } catch ( Exception^ e ) { // Expected exception if a file cannot be found. This indicates that we have a new user. String^ errorMessage = e->ToString(); return true; } }
for the ability to access unmanaged code. Associated enumeration: SecurityPermissionFlag::UnmanagedCode Security action: LinkDemand.
requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.
Available since 1.1