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)

Syntax

public abstract string RootPath { get; internal set; }
public:
property String^ RootPath {
    virtual String^ get() abstract;
    internal: virtual void set(String^ value) abstract;
}
abstract RootPath : string with get, internal set
Public MustOverride Property RootPath As String
    Get
    Friend Set
End Property

Property Value

Type: System.String

Type: System.String

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

Remarks

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);
}

See Also

RoleEnvironment
LocalResource Class
Microsoft.WindowsAzure.ServiceRuntime Namespace

Return to top