VB.NET - Deploying an .accdb file so that is it not Read Only

Asked By Greg on 31-Jan-11 02:53 PM
I have created a project in VS2010 that connects to a .accdb file.  However, I am having troubles deploying the .accdb file to a directory that does not make the file read only in Vista. 

What folder should be created in the 'File System' and then what should the connection string be in the app.config file?

and also, is there another setting somewhere to keep the accdb file from becoming read only in vista?
Peter Bromberg replied to Greg on 31-Jan-11 03:05 PM
Not sure how your file became readonly unless it was already so when you created. You can use the attrib command to remove attributes on a file, e.g.

attrib -r myfile.accdb

would remove the read only attribute from myfile.accdb

Greg replied to Peter Bromberg on 31-Jan-11 03:37 PM
Oddly, when I go to the properites of the accdb file, the read only atribute is not selected.  However when I open the accdb file, it states that it is read only and that I can save as to remove read only.  So i am not sure if programmatically changing the attribute would work, but will try it nonetheless.  thanks.

What folder would you install the accdb file to?  and what would be the path for the connection string in the app.config file so that everything would work in XP and Vista?  It seems when i attempt to use |CommonAppDataFolder|...it doesnt see this as a directory.  However, it sees |DataDirectory| as a directory. 
Peter Bromberg replied to Greg on 31-Jan-11 04:13 PM
DataDirectory should work.
Greg replied to Peter Bromberg on 31-Jan-11 04:24 PM
Yes DataDirectory does work for installation, but unfortunately that installs the accdb file to the Program Files.....  In vista and W7 that is a nono from what i understand.  So I need to install to the ProgramData directory...at least from what I understand, but also make sure the accdb file is not read only. 
Peter Bromberg replied to Greg on 31-Jan-11 05:14 PM
Well there are no-no's and there are maybe's. The main thing is not so much what folder the file gets placed in, so long as your application knows the correct path and the folder is not marked readonly. The OS itself really doesn't care where you put the file.
Greg replied to Peter Bromberg on 31-Jan-11 06:47 PM
Well I went ahead and just kept the accdb file in the program Files directory and attempted to change the read only attribute, but unfortunately, i get an error stating "Access to the path......is denied."  so much for changing the readonly attribute.  Plus as i have said before, the attribute doesnt seem to be ready only anyways, just when i open the file does it tell me it is read only.

I realize the OS doesnt care where the file is located, but I thought it was a Microsoft thing that they did not want you putting editable files in the Program Files.