Export (0) Print
Expand All

LocalResource.RootPath Property

Updated: October 18, 2011

Gets the full directory path of the local storage resource.

Namespace: Microsoft.WindowsAzure.ServiceRuntime
Assembly: Microsoft.WindowsAzure.ServiceRuntime (in Microsoft.WindowsAzure.ServiceRuntime.dll)

public abstract string RootPath { get; }

Property Value

Type: System.String

A String that contains the full directory path of the local storage resource.

If your service is running in the Windows Azure Compute Emulator, the local storage resource is defined within the local file system of your development computer. When your hosted service is deployed to Windows Azure, the path to the local storage resource includes the deployment ID.

Local storage resources are defined in the ServiceDefinition.csdef file. For more information about defining local storage resources, see the How to Configure Local Storage Resources.

The following example shows how to create an instance of LocalResource and write a text file by using the path that is returned from the object:


// Retrieve an object that points to the local storage resource
LocalResource localResource = RoleEnvironment.GetLocalResource("localStoreTwo");

//Define the file name and path
string[] paths = { localResource.RootPath, "MyStorageTest.txt"};
String filePath = Path.Combine(paths); 

using (FileStream writeStream = File.Create(filePath))
{
   Byte[] textToWrite = new UTF8Encoding(true).GetBytes("Testing Web role storage");
   writeStream.Write(textToWrite, 0, textToWrite.Length);
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Windows Vista, Windows 7, Windows Server 2008, Windows 8.1, Windows Server 2012 R2, Windows 8 and Windows Server 2012

Target Platforms

Community Additions

ADD
Show:
© 2014 Microsoft