MkDir: Permissions not being set |
|
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
|
Re: MkDir: Permissions not being set |
|
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
>
>
|
Re: MkDir: Permissions not being set |
|
"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
|