Setting a file attribute to System or Hidden

jal

Registered User.
Local time
Today, 07:04
Joined
Mar 30, 2007
Messages
1,709
I have an Access 2003 MDB file.

On Form1_Open it creates a logfile on the CDrive. (This is info that I do not wish to store in the database).

But I want this logfile to be invisible to reduce clutter and prevent accidental deletion. So I set the file attribute to Hidden.

But some users (like me) display hidden files. However, most users do not display system files. So I set the file attribute to System.

And here's my question. Marking a file as a System file can't possibly interfere with system operations, can it? I don't want to cause any system problems.

BTW, the name of the logfile is ListOfBackupFolders.Txt
 
I would foresee no problems with that. Many Developers will make a folder under C:\Windows for these files. As a user, I would personally prefer that over dumping it in the C: Root folder. Or, also common, keep it in the same folder as your MDB.
 
I agree, you shouldn't see any problems with that. The chance of that filename causing any sort of conflict within Windows is nigh on nil.

I like the suggestion of adding a folder under C:\Windows for your supporting files - this adds yet another level of protection from interference or accidental deletion as most users - even the very advanced ones - spend relatively little time browsing in C:\Windows.
 
And I recall now a thing with Vista and Security.... Many (most?) IT Groups do NOT give users read/write permissions to folders under C:\Program Files. As we know, users require R/W access to the location storing the .MDB files (for creating .LDB files). In that a .MDB is essentially a "Document" (the 'application' is msaccess.exe or launchaccess.exe), it doesn't belong under C:\Program Files anyway! Many, thusly, create a folder named "C:\Program Data" and their "documents" are installed under it.
 
Can you tell me what code to use to set the attributes to hidden and system from within access?

Thanks
 
I used the FileSystemObject (add a reference to Windows Scripting Host). Or use late binding if you prefer. It's a bitmask, as far as I know, so you have to use the "OR" keyword to add each attribute:


Dim fso As New IWshRuntimeLibrary.FileSystemObject
Dim oFile As IWshRuntimeLibrary.File
Set oFile = fso.GetFile("C:\myFile.txt")
oFile.Attributes = oFile.Attributes Or Hidden Or System
 
Try this, it did the trick for me:
techonthenet.com/excel/formulas/setattr.php
 

Users who are viewing this thread

Back
Top Bottom