In my vb.net project, I want to save a ima in a folder, but I have this error:
System.UnauthorizedAccessException: Access to the path '\192.168.100.1\T-Dev\Docs\AGRFOB6NV0UM835B59MX34KT2.jpg' 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, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at System.Web.HttpPostedFile.SaveAs(String filename) at P_ControlDoc46.Controllers.U_controldocController.UploadFile(HttpPostedFileBase postedFile, String descricao) in C:\Users\Pedro Moreira\Desktop\P_ControlDoc46\Controldoc-trimalhas\P_ControlDoc46\Controllers\U_controldocController.vb:line 146/DocsTeste/AGRFOB6NV0UM835B59MX34KT2.jpg
The code that I use to save the file is the following:
Try
'Save the Byte Array as Image File.
Dim filePath As String = Server.MapPath(String.Format(WebConfigurationManager.AppSettings("DocsFolder") + "{0}.jpg", fileName))
postedFile.SaveAs(filePath)
Catch ex As Exception
Console.WriteLine(ex)
Return RedirectToAction("IndexCreate", "U_controldoc")
End Try
Can someone help me?
Thanks