hi everyone,
in my project i want to deny users to delete my log file (x.txt) i searched but i couldnt get any answer about this topic in this forum.
in fact, my subject is that, i will create a file as a log file (X.txt). If i want to delete it i will set a specific property such as "canDelete" as True, it will be allowed to delete from anybody, how ever if i set canDelete=False, nobody will delete it.
is it possible?
waiting you suggestions,
thanx
Loading
Ali Emrah PEKESENPosted Aug 23, 2010, 3:49 AM
i asked it for mobile applications, not about web applications, so there isnt any web.config or app.config in my application. i try to make it with windows identifier permission's capability. I must change these capabilities with c sharp on my pda :(
thanx for reply..
ShankeyPosted Aug 20, 2010, 8:57 AM
Hi Ali,
For this you can set trust level for the users that can be one of the following:You just need to make following highlighted changes in your web config:
"Dont forget to mark my answer as accepted if it helped you :)"
Web.config
Your aspx page:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
DirectoryInfo dirInfo = new DirectoryInfo("E:\\temp");
dirInfo.Attributes = FileAttributes.ReadOnly;
FileInfo[] rgFiles = dirInfo.GetFiles("*.txt");
foreach (FileInfo fi in rgFiles)
{
fi.Delete();
}
}
catch
{
Response.Write("You are not allowed to delete files");
}
}
}