Directory.GetAccessControl fails

V

Victory

Hi,
I am using C# to analyze data from some customer. The have
a disk which i don't know where it came from. On this disk,
there is a directory called "bb label.qxd ". If you notice
there is a space in this name. The extension i found out
that is a QuarkExpress. When i use the explorer, i see this
as a directory, when i open it, there are files within it.
But my code, goes through the exception block with message
being the full path to the directory and nothing else. I
rebooted my system and still get the same thing. I examined
the exception and i see these numbers:(HResult -2147024893)
and (COM -532459699). I used the Immediate window and
before my crash point, tried File.Exists(sDir) and
Directory.Exists(sDir) but both of them cause the same
exception. Any ideas?

private void getDirectoryFiles(ArrayList fC, string
sRoot)
{

//read all the directory names in the root
provided
string[] sDirs = new string[1];
try
{
if
(Directory.GetAccessControl(sRoot).AreAccessRulesProtected
== false)
{
sDirs =
Directory.GetDirectories(sRoot); //<---- Access Denied
error
}
}
catch (Exception e)
{
m_bDirError = true;
LogError("Directory access error: " +
e.Message);
}
if (!m_bDirError)
{
foreach (string sDir in sDirs)
{
if (this.m_bCancel == false && sDir !=
null)
{
try
{
if
(Directory.GetAccessControl(sDir).AreAccessRulesProtected
== false)
{
if
(((File.GetAttributes(sDir) & FileAttributes.ReparsePoint)
!= FileAttributes.ReparsePoint))
{
getDirectoryFiles(fC,
sDir);
}
}
}
catch (Exception e)
{
m_bDirError = true;
LogError("Directory <" + sDir +
"> access error: " + e.Message);
}
try
{
if
(Directory.GetAccessControl(sRoot).AreAccessRulesProtected
== false)
{
string[] sFiles =
Directory.GetFiles(sRoot);
fC.Add(sFiles);
}
}
catch (Exception e)
{
m_bDirError = true;
LogError("Directory <" + sRoot + ">
access error: " + e.Message);
}
}
Mars
 
V

Victory

I tried creating a DirectoryInfo before the crash point, i
saw that the Windows XP has internally removed the trailing
space on the directory name. So, it appears "bb label.qxd"
without the trailing space. That is why
DirectoryInfo.GetAccesControl fails. because there is no
file with this name. So, this one is not about my code
being wrong. It is perhaps about Windows not being able to
handle this scenario i.e. trailing spaces at the end of
directories. We know we can't create a file or directory
with a trailing space in the extension, can we?
regards,
Mars
 
V

Victory

I tried creating a DirectoryInfo before the crash point, i
saw that the Windows XP has internally removed the trailing
space on the directory name. So, it appears "bb label.qxd"
without the trailing space. That is why
DirectoryInfo.GetAccesControl fails. because there is no
file with this name. So, this one is not about my code
being wrong. It is perhaps about Windows not being able to
handle this scenario i.e. trailing spaces at the end of
directories. We know we can't create a file or directory
with a trailing space in the extension, can we?
regards,
Mars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top