c# - Access Denied!? I cant open a file from my install folder on the C Drive -


enter image description herewhat doing wrong?

i have read/copy/write process access folder installed software.

this worked great when testing build, once solution created stopped working. doing wrong?

(breakdown of code) access pdf called ctw.pdf next create temp copy software fills in , flatted on completion, software saves new copy same directory new name (i add time , date file name)

here's code:

if (screenlock.text == "") {  } else {     string filenameexisting = @"c:\program files (x86)\compliance pro 2\ctw.pdf";     string filenamenew = @"c:\program files (x86)\compliance pro 2" + " ctw.pdf" + datetime.now.tostring("m/d/yyyy") + datetime.now.tostring("hh:mm:ss");      using (var existingfilestream = new filestream(filenameexisting, filemode.open))     using (var newfilestream = new filestream(filenamenew, filemode.create))     {         // https://www.codeproject.com/tips/679606/filling-pdf-form-using-itext-pdf-library          // open existing pdf         var pdfreader = new pdfreader(existingfilestream);         // pdfstamper, create         var stamper = new pdfstamper(pdfreader, newfilestream);         var form = stamper.acrofields;         var fieldkeys = form.fields.keys;         foreach (string fieldkey in fieldkeys)         {            form.setfield(fieldkey, "");         }         stamper.acrofields.setfield("osjnonosj", "tfsn");         stamper.acrofields.setfield("branch", "9dcf");         stamper.acrofields.setfield("user name last first", "joe" + "pearson");         stamper.acrofields.setfield("tested last first", emailto.text);         stamper.acrofields.setfield("date tested", datetime.now.tostring("m/d/yyyy"));         stamper.acrofields.setfield("comments", notes.text);         stamper.acrofields.setfield("wde-yes", user.text + "5");     } } 

note: have worked hard ensure software not require administrative access complete it's functions, avoid here well.

putting file directly c:\ or trying rwrite there poor choice. practically every relevant folder of windows drive protected, need @ least adminsitrative privileges write them. without those, can not asume write rights programm directory (and if can that, should not placing data there).

if want place can write , store data, specialfolders. userprofile specific folders in particular designed should have access normal user. use publics ones if data shared between users, otherwise profile ones.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -