February 2010
Beginner
400 pages
11h 13m
English
Local storage is an area to which you can temporarily save files, and it can be useful for caching, uploading, and serialization. Warning—you should not save anything here you want to keep since local storage will be cleared if your application restarts.
To use local storage, simply add a new entry to ServiceDefinition.csdef to define the storage area:
<LocalStorage name="MyStorage"/>
Once you have defined the storage, you can now use the RoleEnvironment.GetLocalResource() method to return a LocalResource object that allows you to utilize the file. The following example shows how to save a file to local storage:
LocalResource resource = RoleEnvironment.GetLocalResource("MyStorage"); string Path = resource.RootPath + "messages.txt"; ...