oledb - ExcelLibrary throwing Unauthorized Access Exception when attempting to create -


as title describes, program throwing unauthorizedaccessexception when attempting create excel file excellibrary library, strange given computer hasn't got restrictions regarding that. code:

using system; using system.collections.generic; using system.componentmodel; using system.data; using system.data.common; using system.drawing; using system.linq; using system.data; using system.data.oledb; using system.text; using system.threading.tasks; using system.windows.forms; using excellibrary; namespace exceltest {     public partial class form1 : form     {         public form1()         {             initializecomponent();         }          private dataset ds;         private void form1_load(object sender, eventargs e)         {             string cs = "provider=microsoft.jet.oledb.4.0;data source=test1.mdb;";             ds = new dataset("new_dataset");             datatable dt = new datatable("new_datatable");             string[] x = new string[20];             (int = 1; < x.length; i++)             {                 x[i] = "a";             }             ds.locale = system.threading.thread.currentthread.currentculture;             dt.locale = system.threading.thread.currentthread.currentculture;             oledbconnection con = new oledbconnection(cs);              con.open();             string sql = "select * personas;";             oledbcommand cmd = new oledbcommand(sql, con);             oledbdataadapter adptr = new oledbdataadapter();             adptr.selectcommand = cmd;             adptr.fill(dt);             con.close();             ds.tables.add(dt);         }          private void button1_click(object sender, eventargs e)         {             excellibrary.datasethelper.createworkbook("c:\\users\\spereyra\\documents\\visual studio 2012\\projects\\deleteme\\exceltest", ds);             messagebox.show("creating excel");         }     }     } 

any ideas of problem be? thanks


edit: exception log (it's in spanish, hope don't mind):

system.unauthorizedaccessexception: acceso denegado la ruta de acceso 'c:\users\spereyra\documents\visual studio 2012\projects\deleteme\exceltest'.    en system.io.__error.winioerror(int32 errorcode, string maybefullpath)    en 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)    en system.io.filestream..ctor(string path, filemode mode, fileaccess access, fileshare share)    en system.io.file.open(string path, filemode mode, fileaccess access, fileshare share)    en excellibrary.compounddocumentformat.compounddocument.create(string file)    en excellibrary.spreadsheet.workbook.save(string file)    en excellibrary.datasethelper.createworkbook(string filepath, dataset dataset)    en exceltest.form1.button1_click(object sender, eventargs e) en c:\users\spereyra\documents\visual studio 2012\projects\deleteme\exceltest\form1.cs:lĂ­nea 51 

found error, had specified route file forgot type filename , extension: instead of

excellibrary.datasethelper.createworkbook("c:\\users\\spereyra\\documents\\visual studio 2012\\projects\\deleteme\\exceltest", ds);                 messagebox.show("creating excel"); 

i should have put

excellibrary.datasethelper.createworkbook("c:\\users\\spereyra\\documents\\visual studio 2012\\projects\\deleteme\\exceltest\\myexcel.xls", ds);                     messagebox.show("creating excel"); 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -