(0) exportieren Drucken
Alle erweitern

RoleEnvironment.GetLocalResource-Methode

Retrieves a specified local storage resource.

Namespace: Microsoft.WindowsAzure.ServiceRuntime
Assembly: Microsoft.WindowsAzure.ServiceRuntime (in microsoft.windowsazure.serviceruntime.dll)

'Usage
Dim localResourceName As String
Dim returnValue As LocalResource

returnValue = RoleEnvironment.GetLocalResource(localResourceName)

'Declaration
Public Shared Function GetLocalResource ( _
	localResourceName As String _
) As LocalResource
public static LocalResource GetLocalResource (
	String localResourceName
)
public static function GetLocalResource (
	localResourceName : String
) : LocalResource

Parameter

localResourceName

The name of the local storage resource that is defined in the ServiceDefiniton.csdef file.

Rückgabewert

An instance of LocalResource that represents the local storage resource.

AusnahmetypBedingung
RoleEnvironmentException

The local storage resource does not exist.

The following code example shows how to use this method to retrieve the local storage resource and write a text file to the resource:


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

Alle öffentlichen statischen (freigegebenen in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Entwicklungsplattformen

Windows XP Home Edition, Windows XP Professional, Windows Server 2003, Windows Server 2008 und Windows 2000

Zielplattformen

Community-Beiträge

Anzeigen:
© 2014 Microsoft