I have a host which is medium trust level, im using imageresizer nuget package for my image processes. So when i'm trying to using ImageBuilder.Build i got this error:
Access to the path '(path)' is denied.
System.UnauthorizedAccessException: Access to the path '(path)' 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, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
at ImageResizer.ImageBuilder.BuildJob(ImageJob job)
at ImageResizer.ImageBuilder.Build(ImageJob job)
at ImageResizer.ImageBuilder.Build(Object source, Object dest, ResizeSettings settings, Boolean disposeSource, Boolean addFileExtension)
at ImageResizer.ImageBuilder.Build(Object source, Object dest, ResizeSettings settings, Boolean disposeSource)
at _10oy.UI.Web.Imager.Models.Downloader.SaveAndSetDimension(String path, Int32 width, Int32 height)
btw: (path)'s edited by me.
I research error but i didn't find any effective result.
here is my code (i'm calling it in threading.timer, it can be issue ?)
public void SaveAndSetDimension(string path, int width, int height)
{
try
{
ImageBuilder.Current.Build(_MainStream, path, new ResizeSettings() { MaxWidth = width, MaxHeight = height }, false);
}
catch (Exception ex)
{
Results.Failed++;
DAL.Classes.Log.Write(
message: ex.Message,
innerexcepition: ex.InnerException != null ? ex.InnerException.ToString() : ex.ToString(),
user: "Saver",
interfaces: 4 //Imager
);
}
}
and i tried regular file create in action
public ContentResult CreateFile()
{
System.IO.File.Create(Server.MapPath("~/myfile.txt"));
return Content("File Created");
}
and its work.
thanks.
edit: When i call it on normal action its working great but when call in timer i got this error.