C# 未找到工作角色localstorage的目录异常

C# 未找到工作角色localstorage的目录异常,c#,azure,c#-4.0,azure-storage-blobs,C#,Azure,C# 4.0,Azure Storage Blobs,在worker role onStart事件中,我正在azure blobstorage上选择一个json文件,并将其下载到worker role的localstorage blockBlob2.DownloadToFile(RoleEnvironment.GetLocalResource("WorkerRoleStorage").RootPath, FileMode.Create); 我收到System.IO.DirectoryNotFoundException,如下所示 System.

在worker role onStart事件中,我正在azure blobstorage上选择一个json文件,并将其下载到worker role的localstorage

  blockBlob2.DownloadToFile(RoleEnvironment.GetLocalResource("WorkerRoleStorage").RootPath, FileMode.Create);
我收到System.IO.DirectoryNotFoundException,如下所示

System.IO.DirectoryNotFoundException was unhandled by user code
  HResult=-2147024893
  Message=Could not find a part of the path 'C:\Users\Arnab\AppData\Local\dftmp\Resources\006f5676-9c7e-4984-bbe7-83abd71f6726\directory\WorkerRoleStorage\'.
  Source=mscorlib
  StackTrace:
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
       at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.DownloadToFile(String path, FileMode mode, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext)
       at WorkerRole1.WorkerRole.OnStart() in d:\uax\CollectorTest1\AzureCloudService1\WorkerRole1\WorkerRole.cs:line 64
       at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(RoleType roleTypeEnum)
       at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRole(RoleType roleType)
       at Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.<InitializeRole>b__0()
  InnerException: 
System.IO.DirectoryNotFoundException未被用户代码处理
HResult=-2147024893
Message=找不到路径“C:\Users\Arnab\AppData\Local\dftmp\Resources\006f5676-9c7e-4984-bbe7-83abd71f6726\directory\WorkerRoleStorage\”的一部分。
Source=mscorlib
堆栈跟踪:
在System.IO.\uuu Error.WinIOError(Int32 errorCode,字符串maybeFullPath)
在System.IO.FileStream.Init(字符串路径、文件模式、文件访问权限、Int32权限、布尔用户权限、文件共享、Int32缓冲大小、文件选项选项、安全属性secAttrs、字符串msgPath、布尔bFromProxy、布尔useLongPath、布尔checkHost)
位于System.IO.FileStream..ctor(字符串路径、文件模式、文件访问权限、文件共享、Int32 bufferSize、文件选项选项、字符串msgPath、布尔bFromProxy)
位于System.IO.FileStream..ctor(字符串路径、文件模式、文件访问)
在Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.DownloadToFile(字符串路径、文件模式、AccessCondition AccessCondition、BlobRequestStoptions选项、OperationContext OperationContext)
在d:\uax\collectorest1\AzureCloudService1\WorkerRole1\WorkerRole.cs中的WorkerRole1.WorkerRole.OnStart()处:第64行
在Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(RoleType RoleTypeNum)上
位于Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRole(RoleType RoleType)
在Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.b_u0()中
内部异常:
但当我尝试访问错误“消息”中显示的路径时,我可以通过m/c到达那里

衷心感谢您的帮助


谢谢

您应该使用本地存储资源,它是运行角色实例的虚拟机文件系统中的保留目录。实例中运行的代码可以在需要写入或读取文件时访问本地存储资源

MSDN参考:


相关帖子:

您应该使用本地存储资源,它是运行角色实例的虚拟机文件系统中的保留目录。实例中运行的代码可以在需要写入或读取文件时访问本地存储资源

MSDN参考:


相关帖子:

这就是问题所在。。RoleEnvironment.GetLocalResource(“WorkErrorStoreAge”)。根路径引发目录未找到异常。这就是问题所在。。RoleEnvironment.GetLocalResource(“WorkErrorStoreAge”)。根路径正在引发目录未找到异常。。