|
Hi guys im creating a folder then adding a user with permissions to that folder but how
do I then set this security permission to apply to this folder, sub folders and files within this folder?
currently it just applys to this folder only.(so when the app creates a file within this folder the file does not inherit the permission's from the folder)
DirectorySecurity dirSec = Directory.GetAccessControl(_dbPath);
dirSec.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.Write, AccessControlType.Allow));
dirSec.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.ReadAndExecute, AccessControlType.Allow));
dirSec.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.CreateFiles, AccessControlType.Allow));
dirSec.AddAccessRule(new FileSystemAccessRule(IdentityReference, FileSystemRights.WriteData,InheritanceLevel,PropagationFlags., AccessControlType.Allow));
Directory.SetAccessControl(_dbPath, dirSec);
|
|
|
|
|
try this:
dirSec.AddAccessRule(new FileSystemAccessRule(IdentityReference, FileSystemRights.WriteData,
InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow));
Edit: Splitted message, because it isn't rendered correctly
modified on Saturday, November 28, 2009 5:23 AM
|
|
|
|
|
Hi
I used reflection many times before on public methods but never realized that private methods can be invoked too. See the link : link
I am still thinking why is that allowed in the first place?
Isn't that going to break the rule of "private" being "private"?
puzzled
AJ
Follow your goals, Means will follow you ---Gandhi---
|
|
|
|
|
It's reflection, the very concept of it breaks all rules - much like arbitrary pointer arithmetic and type punning
That doesn't matter though, these things are useful in practice, The Rules are mostly of theoretical value (for example to be able to prove things about programs) and are only guidelines in the Real World.
|
|
|
|
|
Hi -
After some nice help from this group, my C# app is working well in debug mode.
However, when I publish it and then run setup.exe, the installation process crashes and makesan error report to sent to Microsoft. The error message (which I understand only parts of) says: "P1 <my app name> P4 mscorlib.dll P9 system.io.file not found exception". I don't know whether this means mscorlib.dll was not found or whether mscorlib.dll could not find a file. In any case, my machine has mscorlib.dll in the .net 2.0 folder. I built the application prerequisites to include .net 3.5 SP1 and also tried additinally listing 2.0. No difference: both crash.
I previously published a small app with no problems, so there must be something that this app needs that is not being found.
Can someone put me on the right path? I've Googled "visual studio 2008 express setup crash" and found nothing helplful.
Thanks -
Chuck
|
|
|
|
|
|
Hi Saksida:
.net 2.0 SP2 is already installed so the problem is something else.
Chuck
|
|
|
|
|
string str2= "";
foreach ( str2 in this.String_Array)
{
if (str2 != "")
{
flag2 = true;
break;
}
}
Error is
Cannot assign to 'str' because it is a 'foreach iteration variable'
Error
Type and identifier are both required in a foreach statement
If you can think then I Can.
|
|
|
|
|
A foreach iteration variable should be declared IN the foreach statement itself. You cannot reuse a previously declared variable, as in the case of 'for' loop.
This should work:
foreach (String str2 in this.String_Array)
Delete the first line that declares str2.
|
|
|
|
|
But the Error Getting Similer. I already use it.
If you can think then I Can.
|
|
|
|
|
Please be more descriptive. Post your code and the error message.
|
|
|
|
|
As Shamel said it, you need to have it like this:
foreach ( String str2 in this.String_Array)
{
if (str2 != "")
{
flag2 = true;
break;
}
}
eg_Anubhava wrote: Cannot assign to 'str' because it is a 'foreach iteration variable'
I frequently got this error, when I tried to change str2 and this.String_Array inside ForEach loop. My workaround was to create temp List, then I changed String_Array outside foreach loop
|
|
|
|
|
thank you sir my meaning is same
If you can think then I Can.
|
|
|
|
|
I Did create empty windows Form, and I Put your sample, and it worked without any error.
Have you posted your actual code? If Not, please post actual foreach loop.
Where and How do you use and initialize String_Array and Flag?
What Exception do you get and at witch line?
|
|
|
|
|
i have found the solution for that:
the solution is : The language does not allow you to reassign a "foreach" variable. Even
if you could, it wouldn't update the contents of hte array. What do
you want to do here? If you want to change the values in the array,
then you will have to do somehing like.
for(int i = 0 ; i < arrfile.Length; i++)
{
str = arrfile[i]
}
If you can think then I Can.
|
|
|
|
|
hi there,
i am trying to bind a textBox with a MS-SQL table fiels in this way:
dataAdapter.Fill(dataSet, tableName);
textBox.DataBindings.Add("Text", dataSet.Tables[tableName], "someField");
the thing is, that while using dataAdapter.Fill() method, the textBox is really filled...BUT when i am making changes in the textBox the modification doesn't reflect in the DB.
what am i missing in order to make this bind 2-way???
thx!
|
|
|
|
|
You're probably not using WPF. I've never heard of text boxes magically doing this, and if they did, I still wouldn't touch it with a barge pole.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Until you've issued a dataAdapter.Update(), changes won't be "reflected in the DB".
"Data binding" deals with controls and sources of data "in memory" (in your case, the DataSet; in other cases, it might be a different type of object, such as an Entity Model query). To get the data from the "in memory" data source to the "data store" (i.e. the "Database") one needs to issue an Update() sometime; the type of Update being dependent on the data source.
|
|
|
|
|
i used this data adapter instance later on when the user clicks on some button.
the INSERT,SELECT,UPDATE,DELETE commands were set.
then :
dataAdapter.Fill(dataSet, tableName);
textBox.DataBindings.Add("Text", dataSet.Tables[tableName], "someField");
and then later on:
da.Update(dataSet, tableName)
doesn't work...
i read somewhere that this binding is not Bi-Directional.
never mind.. thx guys anyway.
eventually i used the SqlDataReader. simple, easy, and... works!
|
|
|
|
|
hi to all, i was wondering if i can get some help,
i'm srawing on tabs of tab control item that has string and a-16X16 pixel icon of cancel button,
(just like the tabs in a regular browser that have a small button to close the tab).
anyway, i'm tring to make the icon on the selected tab to be red and the other tabs gray.
here is the code:
private void tabControl1_DrawItem(object sender, DrawItemEventArgs e)
{
Image img1 = new Bitmap(Application.StartupPath + "\\icons\\cancelGray.png");
Image img2 = new Bitmap(Application.StartupPath + "\\icons\\cancelRed.png");
Rectangle r = e.Bounds;
r = this.tabControl1.GetTabRect(e.Index);
r.Offset(2, 4);
Brush TitleBrush = new SolidBrush(Color.Black);
Font f = new Font("Microsoft Sans Serif", 8.0f);
string title = this.tabControl1.TabPages[e.Index].Text;
e.Graphics.DrawString(title, f, TitleBrush, new PointF(r.X, r.Y));
foreach (TabPage tp in tabControl1.TabPages)
{
if (tp == lastSelected) //LAST SELECTED IS THE THE CURRENT TABPAGE THAT SELECTED.
e.Graphics.DrawImage(img2, new Point(r.X + (this.tabControl1.GetTabRect(e.Index).Width - _imageLocation.X) - 7, _imageLocation.Y));
else e.Graphics.DrawImage(img1, new Point(r.X + (this.tabControl1.GetTabRect(e.Index).Width - _imageLocation.X) - 7, _imageLocation.Y));
}
}
the problem is that the changing colors of the tabs is not correct, i can't figure why when i'm clicking one tab the other is change..
thanks,
modified 31-Dec-20 21:02pm.
|
|
|
|
|
Hi,
in general events may fire more often than you would expect, so it is unwise to use status information from elsewhere when this can be avoided, as such data might be incorrect.
More in particular: why are you using your lastSelected when you have TabControl.TabPages[TabControl.SelectedTab] which is bound to always be the correct current page?
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
what do you suggest instead of the foreach?
and i tried the tabControl1.SelectedTab instead of the lastSelected before, it's only a bad try to fix the problem.
modified 31-Dec-20 21:02pm.
|
|
|
|
|
sagiko wrote: what do you suggest instead of the foreach?
Nothing.
I can't help you any further lacking precise scenarios and symptoms.
sagiko wrote: it's only a bad try to fix the problem
that does not help at all.
To be as vague as you are: fix the problem.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
modified 31-Dec-20 21:02pm.
|
|
|
|
|
Hi all.
I am trying to delete a directory and using
Directory.Delete("some_file_path");
These works just fine if the directory has no files in it but if it has any file, it does not get deleted. What should i do to delete a directory with or without a file?
Wamuti: Any man can be an island, but islands to need water around them!
Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.
|
|
|
|