Trying to create folder in filesystem. But it doesn't work for general domain users, only for admins.
I've tried
_strArticlePath = SPUtility.GetGenericSetupPath(Path.Combine(_strArticleStoragePath, strArticleId));
SPUserToken sysToken = null;
using (var spSite = new SPSite(SPContext.Current.Site.ID))
{
sysToken = GetSystemToken(spSite);
using (var impersonatedSite = new SPSite(SPContext.Current.Site.ID, sysToken))
{
using (var web = impersonatedSite.OpenWeb())
{
try
{
Directory.CreateDirectory(_strArticlePath);
}
catch (Exception ex)
{
WriteLog("Create Directory", ex.Message);
}
}
}
}
and this one
SPSecurity.RunWithElevatedPrivileges(delegate
{
using (var site = new SPSite(SPContext.Current.Site.ID))
{
using (var impersonateWeb = site.OpenWeb(SPContext.Current.Web.ID))
{
impersonateWeb.AllowUnsafeUpdates = true;
Directory.CreateDirectory(_strArticlePath);
}
}
});
And both doesn't work. Advise pls.