繁体   English   中英

如何访问Azure Webrole中作为部署一部分的文件

[英]How can I access a file that's part of the deployment in an Azure Webrole

我们有一个WCF服务,已部署到客户服务器,现在我们正在创建一个webrole,使我们能够在Azure上运行相同的服务。 问题在于服务项目有一个img文件夹,其中存储了一些文件丢失或用作徽标时使用的图像。 当我们的服务尝试使用此行代码访问该文件时

File.Open(StoragePath, FileMode.Open);

我们得到以下异常:

System.UnauthorizedAccessException: Access to the path 'E:\sitesroot\0\bin\img\delficertwarning.tif' is denied.
 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)
 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, FileShare share)

有谁知道如何使它工作?

事实证明,您必须指定只使用打开的文件进行读取:

File.Open(StoragePath, FileMode.Open, FileAccess.Read, FileShare.Read);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM