c# - File permission (write) -
hello,
once got code work out erros, , downloaded file.
gives me permission error,
don't acesscontrol pop window should show.
anyways,
how can code download file?
webclient request = new webclient(); request.credentials = new networkcredential(txtftpuser.text, txtftppassword.text); byte[] filedata = request.downloaddata(fulldownloapath);//dnoces.dreamhost.com filesecurity security = file.getaccesscontrol(downloadto); filesystemaccessrule rule = new filesystemaccessrule(@"builtin\users", filesystemrights.fullcontrol, accesscontroltype.allow); file.setaccesscontrol(downloadto, security); try { filestream f = file.create(downloadto/*+@"\"+file*/); f.write(filedata, 0, filedata.length); f.close(); messagebox.show("completed!"); } catch(exception e) { messagebox.show(e.message); }
what in 'downloadto' variable ? i'm little confused code. since can perform getaccesscontrol() assume must contain folder. if file, fail because doesn't exist yet.
but code continues
filestream f = file.create(downloadto/*+@"\"+file*/);
since wrote /* */ 'file' variable commented, makes me assume downloadto must contain full path including filename.
can try , hardcode destination file ?
(e.g. filestream f = file.create(@"c:\\users\\your user\\myfile.bin");
as far can interpret code you're trying write folder such without specifying filename.
Comments
Post a Comment