Read Write

I have an Access MDB file on a install disc which my install program copies to the users computer. Trouble is after its copied it ends up as Read only. What is the code for changing it to Read/Write
LVL 3
JeffvClaytonAsked:
Who is Participating?
 
DhaestCommented:
If File.GetAttributes(yourFileName) = FileAttributes.[ReadOnly] Then
    File.SetAttributes(yourFileName, FileAttributes.Normal)
End If
0
 
bmatumburaCommented:
You can include a batch file that will also be installed by the installer which removes the read-only attribute when it is executed. The installer should run this batch file after copying the database. The contents of the batch file follow:
@ECHO off
attrib -r -h -s *.mdb

Open in new window

0
 
DhaestCommented:
To remove an attribute use System.IO.File.SetAttributes. Ex:

if(File.GetAttributes(savedCardFilePath) == FileAttributes.ReadOnly)
File.SetAttributes(savedCardFilePath, FileAttributes.Normal);
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
JeffvClaytonAuthor Commented:
DHaest,

can you translate the above code to VB.Net?
0
 
JeffvClaytonAuthor Commented:
I alread tries that but GetAttributes is not a property of System.IO.FileInfo
0
 
JeffvClaytonAuthor Commented:
Sorry I already used the word File as a System.IO.FileInfo variable
0
 
JeffvClaytonAuthor Commented:
 If IO.File.GetAttributes(MyFile) = IO.FileAttributes.ReadOnly Then
             IO.File.SetAttributes(MyFile, IO.FileAttributes.Normal)
   End If
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.