c# - Storing a file in an existing/ created folder keep saying access denied -
trying upload file created folder error keeps coming
access path 'c:\users\joe\documents\visual studio 2015\projects\training\site1\site1\content\productimages' denied.
and below this
exception details: system.unauthorizedaccessexception: access path 'c:\users\joe\documents\visual studio 2015\projects\training\site1\site1\content\productimages' denied.
asp.net not authorized access requested resource. consider granting access rights resource asp.net request identity. asp.net has base process identity (typically {machine}\aspnet on iis 5 or network service on iis 6 , iis 7, , configured application pool identity on iis 7.5) used if application not impersonating. if application impersonating via , identity anonymous user (typically iusr_machinename) or authenticated request user.
to grant asp.net access file, right-click file in file explorer, choose "properties" , select security tab. click "add" add appropriate user or group. highlight asp.net account, , check boxes desired access.
source error:
line 73: var path = server.mappath("~/content/productimages"); // guardo en la variable path la direccion donde quiero guardar las imagenes, este path es un string que tu lo conformas segun el interes, puedeser upload/nombre_fichero/fecha/etc line 74: string pathdir = path.combine(path, imagename); *line 75: file.saveas(path); // store file* line 76: var imagen = new image(); line 77: imagen.imagepath = pathdir;
and line 75 in red when checking granted rigths there no restriction storing or in file stored
the security coming os, not compiler. navigate folder in windows, right-click, change security.
if deploying, sure use folder automatically granted write permissions .net - user/appdata/roaming folder.
edit: saying you've added folder , given them full control still getting no joy. please try test:
private static void writetext() { using (textwriter tw = new streamwriter(@"c:mytestfile.txt")) { tw.writeline("hello world",false); tw.close(); } }
run above solution, check debug folder solution (i've forgotten @ point if we're dealing console or form or web, may have search computer mytestfile.txt file after running).
the point in running c: (with no backslash) points project folder , automatically have adequate permissions write. if works , mytestfile.txt after running, go in 1 direction. if access error, go in direction. please run in solution or new console app (your solution best) , report results. have patience buddy - we'll best can need be!
Comments
Post a Comment