Skip to Content
Introducing .NET 4.0: with Visual Studio 2010
book

Introducing .NET 4.0: with Visual Studio 2010

by Alex Mackey
February 2010
Beginner content levelBeginner
400 pages
11h 13m
English
Apress
Content preview from Introducing .NET 4.0: with Visual Studio 2010

16.5. Local Storage

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"; ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

ASP.NET 3.5 For Dummies®

ASP.NET 3.5 For Dummies®

Ken Cox
ASP.NET 4 Unleashed

ASP.NET 4 Unleashed

Stephen Walther, Kevin Hoffman, Nate Dudek

Publisher Resources

ISBN: 9781430224556Purchase book