gpt4 book ai didi

c# - 辅助角色 localstorage 的目录未找到异常

转载 作者:行者123 更新时间:2023-12-03 04:33:42 25 4
gpt4 key购买 nike

在辅助角色 onStart 事件中,我在 azure blobstorage 上选择一个 json 文件并将其下载到辅助角色的本地存储中。

  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:

但是当我尝试访问错误“消息”中显示的路径时,我可以通过我的 m/c 到达那里..

真诚感谢任何帮助..

谢谢

最佳答案

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

MSDN 引用:https://msdn.microsoft.com/en-us/library/azure/hh974419.aspx

相关帖子:Could not find a part of the path on windows azure

关于c# - 辅助角色 localstorage 的目录未找到异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31811515/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com