내보내기(0) 인쇄
모두 확장

RoleEnvironment.GetLocalResource 메서드

Retrieves a specified local storage resource.

네임스페이스: Microsoft.WindowsAzure.ServiceRuntime
어셈블리: Microsoft.WindowsAzure.ServiceRuntime(microsoft.windowsazure.serviceruntime.dll)

‘사용 방법
Dim localResourceName As String
Dim returnValue As LocalResource

returnValue = RoleEnvironment.GetLocalResource(localResourceName)

public:
static LocalResource^ GetLocalResource (
	String^ localResourceName
)
public static LocalResource GetLocalResource (
	String localResourceName
)
public static function GetLocalResource (
	localResourceName : String
) : LocalResource

매개 변수

localResourceName

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

반환 값

An instance of LocalResource that represents the local storage resource.

예외 형식조건
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);
}

이 형식의 모든 public static(Shared, Visual Basic의 경우) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

개발 플랫폼

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

대상 플랫폼

커뮤니티 추가 항목

표시:
© 2014 Microsoft