Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Updated 16-Apr-13 0:16am
v4
Comments
Richard MacCutchan 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 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.
[no name] 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

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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900