Featured post
security - Getting System.UnauthorizedAccessException while trying to write to a file from the web service -
my code:
[webmethod] public string helloworld() { string path = @"d:\data\wwwroot\myservice\myservice\log.txt"; if (file.exists(path)) { using (streamwriter sw = new streamwriter(path)) { sw.write("some sample text file"); return "wrote file"; } } else { return "file doesnt exist"; } }
what getting is: system.unauthorizedaccessexception: access path 'd:\data\wwwroot\myservice\myservice\log.txt' denied. @ system.io.__error.winioerror(int32 errorcode, string maybefullpath) @ 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) @ system.io.filestream..ctor(string path, filemode mode, fileaccess access, fileshare share, int32 buffersize, fileoptions options) @ system.io.streamwriter.createfile(string path, boolean append) @ system.io.streamwriter..ctor(string path, boolean append, encoding encoding, int32 buffersize) @ system.io.streamwriter..ctor(string path) @ linktagoutwebservice.service1.helloworld() in d:\data\wwwroot\myservice\myservice\service.asmx.cs:line 29
any security settings need? log file set red/write....
issue solved, permissions issue. have grant iis user app running under permission write file.
- Get link
- X
- Other Apps
Comments
Post a Comment