January 18, 2014
remove uses DeleteFile, but MSDN says
To remove an empty directory, use the RemoveDirectory function.

so remove probably won't work on directories.
January 20, 2014
On Sat, 18 Jan 2014 11:33:16 +0000, Kagamin wrote:
> On Friday, 17 January 2014 at 12:52:09 UTC, Hugo Florentino wrote:
>> On Fri, 17 Jan 2014 07:07:35 +0000, Kagamin wrote:
>>> Does it fail for that one directory only or for any directory?
>>
>> Interesting question. I would have to do more tests with odd names, but apparently both remove() and rename() have problems with directories with a blank name.
>
> In that case try a path with \\?\ prefix (unparsed path).


Does not work. I modified the relevant block like this:

  if (exists(BlankDirToDelete))
  {
    string SafeToBeDeleted = buildPath(`\\?\`, SearchPath, baseName(BlankDirToDelete));
    writefln(`"%s"`, SafeToBeDeleted);
    try
      remove(SafeToBeDeleted);
    catch (FileException e)
      writeln(e.msg);
    try
      remove(`\\?\` ~ SafeToBeDeleted);
    catch (FileException e)
      writeln(e.msg);
  }

The result?

"d:\ "
d:\ : Access denied.
\\?\d:\ : Access denied.

This happens even while executing the prompt as administrator, so it's not a problem of file privileges. Note that from the Windows explorer I am also having problems renaming or deleting the problematic directory, however with something else like Total Commander, I can both rename and delete with no issues.

Regards, Hugo
January 20, 2014
On Sat, 18 Jan 2014 11:51:48 +0000, Kagamin wrote:
> remove uses DeleteFile, but MSDN says
> To remove an empty directory, use the RemoveDirectory function.
>
> so remove probably won't work on directories.

You are correct, so I made a few test using rmdir() with a blank for directory name and now I get:

d:\ : Directory is not empty.

However, the diretory is certainly empty. Go figure!

Note that in Windows I cannot create a directoy with a blank name from D either, so in order to test this, I have to create it elsewhere.
January 20, 2014
Update: the combination of both your suggestions worked:

  if (exists(BlankDirToDelete))
  {
    try
      rmdir(`\\?\` ~ BlankDirToDelete);
    catch (FileException e)
      writeln(e.msg);
  }

Thanks! Now I just have to find out why the block of the file extensions is failing.
1 2
Next ›   Last »