HELP: CREATING UNREMOVE-ABLE FOLDERS?!

Hello. I wrote a flash cards program that allows you to save sets of flash cards in a folder called "saved" and the subfolder which is named by the user. The problem is if the USER NAMES THE FOLDER SOMETHING THAT PRECEDES "...", that entire folder "cannot be found. You can see it in the folder viewer, and even look at the files inside it. But when you try to make any attribute changes, move it, copy it, etc., "the directory does not exist". I believe it has somthing to do with the name. I made 2 saves: 1 called "totoo", the other "totoo...". "totoo" was deleted by me, but when i tried to delete "totoo..." it couldnt find the directory address. If there is anything i can do to remove/name-change the folder, I would SOOOOOO very much appreciate it!! This is a bug i will be fixing (so this must be what happens when 'special' characters are allowed in a folder name huh?).
I'm having a hard time following what you're saying. Can you clarify a bit more?

Your program can see the folder, but it can't modify it? I doubt the name of the folder has anything to do with it.
Last edited on
Get a linux live cd and delete it from there :)

Windows has some name limitations, which NTFS/FAT32 filesystems doesn't.

Or try to use UNC paths to circumvent this limitation.
Get a linux live cd and delete it from there :)


It's cute how Linux enthusiasts like to suggest "use Linux" as a fix for even the most trivial problems in Windows.

But then I suppose they are the type that enjoy doing lots more work than necessary in order to do simple tasks -- hence why they use Linux.
Disch, shutup. Modoran is trying to be helful, unlike you. Any other pesimistic resposes will be promptly reported. I'm getting sick of it. Go to some other forum for that.

By the way, i have Backtrack Linux on a flash drive. It isnt that hard to boot up on an alternate OS. So, i will try that. TY Modoran.
Last edited on
Disch, shutup. Modoran is trying to be helful, unlike you. Any other pesimistic resposes will be promptly reported. I'm getting sick of it. Go to some other forum for that.


u mad?

*pessimistic response*
Last edited on
I was trying to be helpful in my original post. It's very unlikely that the name of a folder is preventing you from deleting it (especially since the name does not contain any unusual characters). I would need more info to determine what's really going on.

modoran was not trying to be helpful, he was being a wiseguy*. "Use a different OS" is about as useful of an answer as "buy a new computer". It was a jab Linux advocates often take when someone posts any kind of problem they're having with Windows because they like to brag about how much better Linux is than Windows. I've seen it enough to recognize it -- maybe you haven't.


That said, if you could show us some code for a small program that reproduces your trouble, I might be able to help you solve it. But I'm still a little unclear on exactly what your problem is. I can say, though, that whatever the problem is, it's very unlikely that the name of the file/folder is the problem. very very unlikely.


* with the 'Linux' comment, anyway. The UNC suggestion was a genuine response



ANOTHER EDIT: But you're right. I shouldn't have responded the way I did. It was immature.
Last edited on
It isnt actually code. All it does is create a folder whose name is predetermined by the user when he/she names it when a prompt is shown. It's the most basic thing. Modoran is right, NFTS filesystems do have that limitation. I would find iut helpful if someone explained how i could circumnavigate this with this so called "UNC" method I've never heard of.
It isnt actually code. All it does is create a folder whose name is predetermined by the user when he/she names it when a prompt is shown.


So this isn't a program you're making? The prompt is just the windows prompt? If so, then what are you putting on the cli to create this folder?


'UNC' is a naming convention you can use when working with paths in WinAPI:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx

Search the page for "\\?\"
@IWishIKnew

The "\\?\" prefix that Disch mentions will allow you to remove your folder. I used the following fragment after my little experiment (see below)

1
2
3
4
5
6
7
8
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

int main() {
	RemoveDirectory("\\\\?\\C:\\Tmp\\Hello...");

	return 0;
}


Out of interest, how are you creating the "totoo..." folder in the first place?

When I use CreateDirectory with the path "C:\Tmp\Hello...", I just get a folder called "Hello", as Windows assumes I've given it an empty extension.

Using the "\\?\" prefix allows me to create the folder, but Explorer really hates it (I'm still using Windows XP at home, and I cannot even see inside the folder).

The safest approach would prob. be to escape your program's folder names so the file system doesn't have to deal with any problematic chars. Though you'll need to make sure you only escape the bits you want to, rather than the whole string, so Windows can still understand the folder hierarchy.

While you could invent your own scheme, I suggest you base it on the one used used to escape URLs. That is, all problematic chars are replace with % + the hex version of their ASCII or UTF-8 encoding
http://en.wikipedia.org/wiki/Url_encoding

For a subfolder called "Hello..." in C:\Tmp, that ends up as
"C:\Tmp\Hello%2e%2e%2e" in Explorer.

If you allow the user to use all prohibited chars as part of their subfolder name, then you'll need to handle at least \/:*?"<>| as well as . and % (as it's used to mark the escaped chars). So over applying it to "C:\Tmp\Hello..." would have ended up with a subfolder called "C%3a%5cTmp%5cHello%2e%2e%2e", probably created in your apps own directory, if you have sufficient access rights.

And then your program has to be able to un-escape it, too.

Andy


Last edited on
Topic archived. No new replies allowed.