Cathal,
thanks for your answer, but this did not really work. What I found out was the following:
01.
string
folder = String.Format(
"{0}myUploadFolder"
,
base
.PortalSettings.HomeDirectoryMapPath);
02.
if
(!(Directory.Exists(folder)))
03.
{
04.
FileSystemUtils.AddFolder(
base
.PortalSettings,
base
.PortalSettings.HomeDirectoryMapPath,
"myUploadFolder"
, Convert.ToInt32(FolderController.StorageLocationTypes.InsecureFileSystem));
05.
}
06.
FolderInfo fi = FileSystemUtils.GetFolder(
base
.PortalId,
"myUploadFolder"
);
07.
08.
if
(fi ==
null
)
09.
FileSystemUtils.SynchronizeFolder(
base
.PortalId, folder,
"myUploadFolder"
,
false
,
true
,
true
,
true
);
10.
11.
FolderPermissionCollection folderPermissions = fi.FolderPermissions;
12.
if
(!(FolderPermissionController.HasFolderPermission(folderPermissions,
"Write"
)))
13.
{
14.
PermissionController permissionController =
new
PermissionController();
15.
ArrayList arr = permissionController.GetPermissionByCodeAndKey(
"SYSTEM_FOLDER"
,
"WRITE"
);
16.
17.
FolderPermissionInfo folderPermission =
new
FolderPermissionInfo();
18.
folderPermission.RoleID = -1;
19.
folderPermission.PermissionID = 6;
20.
folderPermission.AllowAccess =
true
;
21.
22.
folderPermissions.Add(folderPermission);
23.
FolderPermissionController.SaveFolderPermissions(fi);
24.
}
When there is any "WRITE" permission on the folder (allowed or denied) for All Users, an exception is fired that there is already a permission defined.
When no permission is set, the permission will be set, but the file is not uploaded. After I log in as Administrator, I see the permission. I log out and try again - and it works.
Any idea?
Best wishes
Michael