RootPath Property
Collapse the table of content
Expand the table of content

LocalResource.RootPath Property


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; internal set; }

Property Value

Type: System.String

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 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);
Return to top
© 2016 Microsoft