LocalResource.RootPath Property
Gets the full directory path of the local storage resource.
Assembly: Microsoft.WindowsAzure.ServiceRuntime (in Microsoft.WindowsAzure.ServiceRuntime.dll)
Property Value
Type: System.StringType: 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); }