Mega Search
23.2 Million


Sign Up

Make a donation  
MkDir: Permissions not being set  
News Group: borland.public.delphi.nativeapi.win32

Hi,

I am trying to create a new directory and save a file inside it like this:

{$IOChecks off}
MdDir('test');
MdDir('test\test2');
{$IOChecks on}

jpeg.SaveToFile('test\test2\file.jpg');

However I am getting an access denied error message. Although my user 
has full access to the application directory itself. That permission is 
not being inherited by the new sub directories.

Do you know how I could set this? Even ensuring that the "Everyone" 
group has full access would be good enough as the data is not at all 
sensitive.

I have also tried this with a CreateDirectory('test\test2',NIL) API call 
and had the same problem.

I would try replacing NIL with a PSECURITYDESCRIPTOR type but I am not 
sure how to go about this.

Thanks for any help,

Mark

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 20-Dec-2007, at 6:07 PM EST
From: Mark Smith
 
Re: MkDir: Permissions not being set  
News Group: borland.public.delphi.nativeapi.win32
Thanks,

That wasn't the only thing I had done wrong.

In my actual code I was using GetUserName to get the name of one of the 
sub directories. Which returns a null terminated string...

So I needed to PChar() that before writing anything to the path... Ooops :)

Remy Lebeau (TeamB) wrote:
> "Mark Smith"  wrote in message 
> news:476aaf9f$1@newsgroups.borland.com...
> 
>> However I am getting an access denied error message. Although my
>> user has full access to the application directory itself.
> 
> You are using relative paths, not absolute paths.  So your code is subject 
> to the process's current working directory at the time, and that directory 
> changes dynamically during a process's lifetime.  So there is no guarantee 
> that you are actually accessing the application directory at all.  You 
> should always use absolute paths to avoid that problem.
> 
> 
> Gambit 
> 
> 

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 20-Dec-2007, at 7:26 PM EST
From: Mark Smith
 
Re: MkDir: Permissions not being set  
News Group: borland.public.delphi.nativeapi.win32
"Mark Smith"  wrote in message 
news:476aaf9f$1@newsgroups.borland.com...

> However I am getting an access denied error message. Although my
> user has full access to the application directory itself.

You are using relative paths, not absolute paths.  So your code is subject 
to the process's current working directory at the time, and that directory 
changes dynamically during a process's lifetime.  So there is no guarantee 
that you are actually accessing the application directory at all.  You 
should always use absolute paths to avoid that problem.


Gambit 



Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 20-Dec-2007, at 10:22 AM EST
From: Remy Lebeau \(TeamB\)