Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ MFC
I am unfortunately writing a simple dialog application that runs on a Vista machine. My dialog has a user control that accepts a string input and builds a directory structure based upon the user text. For the first two weeks all was well. It created the directory tree and put files where they were suppose to go but this week something has changed and while it still creates the directory structure correctly, it will not let me ( or anyone else ) delete the tree when finished with it. The error message explains that the file is no longer where I said it was which I suspect is really a response to the folders all having the read-only bit set. Of course I can not remove the read-only flag for the same reason that I can not delete the file ( file is no longer where I said it was). I am thinking that I need to explicitly set the security in the SECURITY_ATTRIBUTES structure. Can anyone point me to a good example of how to implement this? Errrgg!!!
 
Ron H.
 
The folders all show up in the GUI view and also in a cmd prompt. The attributes show read-only but I can not remove it either using the properties dialog or with attrib -R.
 
Ron H.
Posted 16-Apr-13 0:45am
(unknown member)
Edited 16-Apr-13 1:16am
v4
Comments
Richard MacCutchan at 16-Apr-13 5:50am
   
Have you actually checked where the file (or directory) is, and what attributes and/or security constraints are set on it?
Matthew Faithfull at 16-Apr-13 5:56am
   
I could dig you out a SECURITY_ATTRIBUTES usage example but it really does sound more like a trashed file system. This sort of thing can happen on NTFS without causing any actual 'failures' like your system not booting anymore. On a FATx system I would expect that much damage to be pretty fatal so it would be useful to know what you're using and if you've done a chkdsk.
Ron Harshbarger at 16-Apr-13 7:05am
   
OK, I ran chkdsk on both internal drives and it reported that it found no problems. Just to be clear, I can see the folders both in the GUI properties window and with the command prompt window however while they show up with dir cmd, attrib "filename" reports that it can not find the specified file. The properties windows shows the read-only flag set and I can not remove it.
 
Ron H.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

OK, Here is what I've discovered. If it is common knowledge, I appologize for the wasted time. I am using ::CreateDirectory(strFilename,NULL) to create the directory tree. I build strFilename from user input. If strFilename == "C:\MyDir\MySubDir" all is well and everything works fine however when strFilename == "C:\MyDir\MySubDir\" the folders are created but strange things happen. The file is visible in explorer and in a cmd prompt window but any attempt to del it or modify it results in essentually a "file not found" error. I do not know why but since I can avoid the issue by avoiding the terminating "\" I can live with it.
 
Regards
Ron H.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 16 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100