|
This doesn't sound like a very nice program. The files on a computer are the user's files and they should be able to delete them if they wish so long as they have the necessary credentials. Most of us have had to deal with 'undeletable' virus and/or spyware & adware files at one time or another and they are a PITA. I can't imagine why you'd want to add this 'feature'.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
I'm sorry,I'm sure that you(DaveyM69) misunderstand my idea!
I have some very important files.Certainly,I don't hope that other people delete them by mistake.
However,thank you all the same for reply!
|
|
|
|
|
Google "C# file permissions" for lots of ideas and code samples.
Also, for .NET 2.0+, see the FileSecurity Class[^].
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
A lot of hostile answers, as it is not the 'polite' thing to do. Users want to control their computer, and they tend to get upset if the computer dictates what they should do.
The nice way of protecting users against accidental deleting would be called a backup-technique. You simply make a copy of the file when the user marks it as 'important'. If someone deletes it, you can always restore the file from your backup.
Good luck
|
|
|
|
|
|
That's not gping to work since the FSW only reports things that have already happened and will only work so long as the app is running.
|
|
|
|
|
That's up to the users to determine, not you or your code. You really can't do what you want unless the user creates a special user account your app has to use that modifies permissions on the files. That way, the permissions get copied with the files if moved to other NTFS volumes and are also backed up during a tape back up. This special account requires its own user name and password that your code would have to manage and generally makes your app more difficult to support in the long run. Not worth the effort...
|
|
|
|
|
hi
am working on hiding data in microsoft word document 2003 .i want hiding data in unused block in doc. file format , so i must finding the offset of BAT ( block allocation Table) the main table for space , i need more information on BAT of doc. file format 2003 (OLE files),details of how i loading the unused Block .......
i wish some one can help me
Thanx
Amani
|
|
|
|
|
Look, it's extrememly unlikely you're ever going to get an answer to this question, no matter how many times you ask it, simply because of the obscurity of the information you're looking for. There are very few people on the planet that have ever messed around with the old OLE file format of Word.
If you want the file format, you can look at this[^].
|
|
|
|
|
Hi,
When should i use this:
protected virtual void OnEvent_PageMenu_Info(string msg)
{
if (Event_PageMenu_Info != null)
{ Event_PageMenu_Info(msg); }
}
and this:
Event_PageMenu_Info(msg);
Sometimes i use one or the other but dont know why
Thanks
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Assuming Event_PageMenu_Info is an event....
What happens if you raise the event before checking for null and
there's nobody subscribed to the event? NULL reference exception
If you've implemented a OnEvent_PageMenu_Info(), then that should be used
to raise te event.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
He could add a do-nothing event handler inside the class that throws the event so that the invocation list is never empty.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I found a neat trick recently - can't remember where.
You can add a dummy handler when declaring the event:
public event EventHandler<...EventArgs> MyEvent = delegate { };
Then the event is never null .
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|
ooooohhhhhh - good tip. That deserves a 5.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Excellent - nice tip Nick - 5'd
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Yeah, as Mark said.
Plus wrapping it in a method allows derived classes to raise the event as well.
|
|
|
|
|
Everything the others have said. Also, Microsoft recommend (and use themselves) a copy to handle the possibility of the event becoming null after the null check but before it's raised. This is the way I implement something like this:
using System;
public class MyPage
{
public event EventHandler<PageMenuInfoChangedEventArgs> PageMenuInfoChanged;
private object _PageMenuInfo;
public object PageMenuInfo
{
get { return _PageMenuInfo; }
set
{
if (_PageMenuInfo != value)
{
_PageMenuInfo = value;
OnPageMenuInfoChanged(new PageMenuInfoChangedEventArgs("Changed!"));
}
}
}
protected virtual void OnPageMenuInfoChanged(PageMenuInfoChangedEventArgs e)
{
EventHandler<PageMenuInfoChangedEventArgs> eh = PageMenuInfoChanged;
if (eh != null)
eh(this, e);
}
}
public class PageMenuInfoChangedEventArgs : EventArgs
{
public PageMenuInfoChangedEventArgs(string message)
{
_Message = message;
}
private string _Message;
public string Message
{
get { return _Message; }
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Thanks everone for the posts
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
Hi guys, if i loop on the attribute collection i can't get the RangeValidator, a custom class objct.
for(Attribute att in attributes)
{
if (att is RangeValidator)
{
Messagebox.show("RangeValidator");
}
}
but if i do like Attribute am= pd.Attributes[typeof(RangeValidator)]; then i am able to get the RangeValidator a custome attribute
public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{
foreach (PropertyDescriptor pd in TypeDescriptor.GetProperties(_obj, attributes))
{
Attribute am= pd.Attributes[typeof(RangeValidator)];--->how come now i can get the RangeValitor this way
}
}
[RangeValidator(10,20)]
public int foo
{
get{return _foo;}
set{_foo=value;}
}
Thanks
|
|
|
|
|
How to activate last textbox in DataGridView on re-activate ?
I created testcase for it:
1. Run code.
2. Enter some data to grid
3. Click other form caption
4. Click original form caption
5. Enter some characters
Observed: entered characters are ignored
Expected: entered characters must appear in last cell before form activation
How to fix ?
using System.Windows.Forms;
public class Test
{
static void Main()
{
Application.Run(new MainForm());
}
}
class MainForm : Form
{
public MainForm()
{
WindowState = FormWindowState.Maximized;
IsMdiContainer = true;
Form frm = new Childform();
frm.MdiParent = this;
frm.Show();
Form frm2 = new Childform();
frm2.MdiParent = this;
frm2.Show();
frm2.Left = 2000;
}
}
class Childform : Form
{
public Childform()
{
var grid = new DataGridView();
grid.Columns.Add(new DataGridViewTextBoxColumn());
grid.EditMode = DataGridViewEditMode.EditOnEnter;
Controls.Add(grid);
}
}
Andrus
|
|
|
|
|
Hello
I'm getting a Graphics with a transformmatrix
Is it possinle to use the graphics without the transformmatrix (set it to null or whatever)
then set back the original matrix
I've tryed .Reset() but it does not work !
Thanks for your help
|
|
|
|
|
I want to open a child window on a seperate thread, from a parent window. The code in parent window should execute seperately and the code in child window should execute seperately.
I tried it using multithreading but couldn't do it. I was able to execute functions as seperate thread but not entire window.
I hope this can be done.
Errors are like Mini Skirts, shorter they get, more revealing they become.
|
|
|
|
|
Can't be done. All Windows, Forms, Controls must be created and manipulated
by the main thread only; if you need additional threads, they should not
touch the Controls, instead they should use the Control.InvokeRequired/Invoke
pattern to tell the main thread to read or write Control properties and call
Control methods in their behalf.
Anything else is bound to fail, either immediately, or at some later time, with
often mysterious phenomena such as disappearing menu bars, windows "Not
responding" and much more.
|
|
|
|
|
Hi,
I have a tabControl in which I add tabPages like so:
TabPage newPage = new TabPage();
NewOrder newOrd = new NewOrder();
newPage.Controls.Add(newOrd);
tabControl1.Controls.Add(newPage);
My application is resizable and the tabControl has anchors so that it resizes with the app. I'm having problems getting the newOrd to resize as well... it stays as a fixed width within the tabPage. I tried using anchors on these objects but it didnt get them to fit correctly. Now I'm trying to bind the newOrd.Width to the newPage.width, but am unfamiliar with how to bind in .Net
Any help is appreciated.
Thanks!
|
|
|
|
|
Hello:
I have just a rudimentary experience so far with programming but want to make my own app in order to do some things that I cannot find a freeware app that does exactly what I want (plus I just want to create something for fun too!)
To help me get started, I wanted to know if anyone can point me to any code examples, tutorials, or a beginner C# programming book that covers:
(1) the very basics of a photo organizer (like Windows Photo Gallery, Picasa, etc.)
(2) the ability to view image metadata (EXIF, IPTC, XMP)
(3) the ability to edit image metadata (EXIF, IPTC, XMP)
I will be using Visual C# 2008 Express and Windows Vista (and in the future would like to work with Windows Home Server)
Anything that gets me going in the right direction would be immensely helpful, thanks!
modified on Friday, October 31, 2008 3:47 PM
|
|
|
|