Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I mark a file as "hidden"

Status
Not open for further replies.

qedusa

Programmer
Jan 12, 2002
43
US
Hi, can anyone tell me how to mark a file as a "hidden" file so it's invisible?
Thanks
 
DWORD attr = GetFileAttributes("C:\\Myfile.txt");
attr |= FILE_ATTRIBUTE_HIDDEN;
if(!SetFileAttributes("C:\\Myfile.txt", attr )) {
AfxMessageBox("Can't change attributes...");
}

You can't make a File invisible at all without play with BIOS disk access or hook Explorer's properties.
 
Also, look into CFileStatus. I believe you can do it there... here is a bit of my code that I used to change the attributes of a file from readonly to read write

Code:
CFileStatus fs;
CFile::GetStatus(fileName,fs);

fs.m_mtime=0;
fs.m_attribute &= ~(CFile::readOnly);

CFile::SetStatus(fileName,fs);

CFile should have a private member named CFile::hidden if not, its valuue is 2 (pretty sure of that)

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top