IsolatedStorageFile.CreateFile Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Creates a file in the isolated store.

Namespace: System.IO.IsolatedStorage
Assembly: mscorlib (in mscorlib.dll)

Syntax

Public Function CreateFile ( _
    path As String _
) As IsolatedStorageFileStream
public IsolatedStorageFileStream CreateFile(
    string path
)

Parameters

  • path
    Type: System..::.String
    The relative path of the file to be created in the isolated store.

Return Value

Type: System.IO.IsolatedStorage..::.IsolatedStorageFileStream
A new isolated storage file.

Exceptions

Exception Condition
IsolatedStorageException

The isolated store has been removed.

-or-

Isolated storage is disabled.

ArgumentException

path is malformed.

ArgumentNullException

path is nullNothingnullptra null reference (Nothing in Visual Basic).

DirectoryNotFoundException

The directory in path does not exist.

ObjectDisposedException

The isolated store has been disposed.

Remarks

This method is equivalent to using the IsolatedStorageFileStream..::.IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare, IsolatedStorageFile) constructor.

Examples

The following example creates files in the root of the store and in its subdirectories. This example is part of a larger example provided for IsolatedStorageFile class.

' Create a file in the root.
Dim rootFile As IsolatedStorageFileStream = _
    store.CreateFile("InTheRoot.txt")
rootFile.Close()


' Create a file in a subdirectory.
Dim subDirFile As IsolatedStorageFileStream = _
    store.CreateFile(Path.Combine(subdirectory1, "MyApp1A.txt"))
subDirFile.Close()
// Create a file in the root.
IsolatedStorageFileStream rootFile = store.CreateFile("InTheRoot.txt");
rootFile.Close();

// Create a file in a subdirectory.
IsolatedStorageFileStream subDirFile =
    store.CreateFile(Path.Combine(subdirectory1, "MyApp1A.txt"));
subDirFile.Close();

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Platforms

Windows Phone

See Also

Reference

IsolatedStorageFile Class

System.IO.IsolatedStorage Namespace