1

お客様のサーバーにデプロイする WCF サービスがあり、Azure で同じサービスを実行できるようにする webrole を作成しています。問題は、サービス プロジェクトに 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)

これを機能させる方法を知っている人はいますか?

4

1 に答える 1

2

開いているファイルを読み取りにのみ使用することを指定する必要があることがわかりました。

File.Open(StoragePath, FileMode.Open, FileAccess.Read, FileShare.Read);
于 2013-07-16T11:02:07.683 に答える