Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Access denied in



Permlink Replies: 1 - Last Post: Oct 23, 2017 9:35 AM Last Post By: Remy Lebeau (Te...
Gerrit Beuze

Posts: 70
Registered: 10/16/00
Access denied in
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 22, 2017 11:47 PM
Hi,

My Delphi 2010 app stores local app data into the directory returned by this
localAppData function:

function GetLocalAppDataPath: string;
var
Buf: array[0..MAX_PATH] of Char;
begin
if SHGetFolderPath(0, CSIDL_LOCAL_APPDATA, 0, SHGFP_TYPE_CURRENT, @Buf) = S_OK then
Result := PChar(@Buf)
else
raise Exception.Create('...');
end;

For example:

Directory := Format('%s\%s\%s\%d.%d\', [GetLocalAppDataPath, 'ModelMakerTools', 'AppName', 1, 0]);
FileName := Directory + 'file.xml';

THis has always worked without problems, however we have recently
started receiving errors from customers like

<ERROR>
Cannot create file:
"C:\Users\<USERNAME>\AppData\Local\ModelMakerTools\AppName\1.0\file.xml"
Access is denied.
</ERROR>

This is always on Windows 10.

When I Google for "access denied local appdata windows 10" there are lots
of hits (also form MS supports) that mention users should correct
(admin) access rights for that folder.

Question:
Is the above described way of storing local app data still OK on Win10?
Anyone else seeing this type of problem + what is the resolution?

Thanks in advance,

Gerrit Beuze
ModelMaker Tools

Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Access denied in
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 23, 2017 9:35 AM   in response to: Gerrit Beuze in response to: Gerrit Beuze
Gerrit Beuze wrote:

THis has always worked without problems, however we have recently
started receiving errors from customers like

<ERROR>
Cannot create file:
"C:\Users\<USERNAME>\AppData\Local\ModelMakerTools\AppName\1.0\file.xm
l" Access is denied.
</ERROR>

Are you creating the folder if it does not already exist, before
creating files in it? If not, you can use SysUtils.ForceDirectories()
for that.

Is the above described way of storing local app data still OK on
Win10?

Of course. Though, you really should be using SHGetKnownFolderPath()
instead of SHGetFolderPath() on Vista+.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02