|
Thanks for the reply.
This not what I meant, if you look in the picture of the article you were kind enough to point me to you see that the big window that houses the smaller ones has menus, I want the offspring to have menus, the windows or forms that contain the picture in the article. How do I do that? That is what I couldn´t do.
Thanks,
FJ
|
|
|
|
|
Hi,
I am currently working on an encryption application. I created a windows service that watches over a directory and when a new file is added, it encrypts it.
Now here is the problem . I want to find out which user has added a file to the directory (which is o n network). Is this possible to find out which user has dropped or added the file to the directory in C#.
Thanks in advance
-Sandeep
.Net Developer
|
|
|
|
|
erm.. depending on the environment that you are using but..
..the owner of the file?
--
michael - www.code.ae
|
|
|
|
|
Hey Micheal,
Its not the file owner. The managers want to know who has dropped the file for encryption. We want the user who dropped the file into the folder in a network.
|
|
|
|
|
This information doesn't exist anywhere. Usually, depending on the network O/S, the person who dropped the file becomes that copy of the file's owner.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for the info.
Is there a way to get the owner details from the file. I use windows XP.
|
|
|
|
|
Well, there's nothing in the .NET BCL that will do this, so alternate methods must be used.
Here[^] is an example in VB.NET using WMI to get the owner.
And here[^] is an example in C++.
I wasn't able to find a straight c# example.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hey Micheal,
Thank you very much. I could convert the VB.NET code to C#. Instead of using WMI i used unmanaged code itself calling all the function manually. It summed up to 40lines code and works fine. Thank you very much for help
|
|
|
|
|
Hi
I am working to programmatically open outlook for reading messages.
But I am getting a security warning dialog box.
How can I disable or stop this box to coming in
thanks
swati
|
|
|
|
|
You can't disable this warning. It's there for a reason. It stops code from trying to impersonate someone and send a whole bunch of emails out, spreading a virus.
You'll have to go into Outlook, Tools/Options/Security Tab (I think!) and manually turn off the option that says "Warn me when an application tries to send mail as me."
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
There are several approaches to this issue.
Extended Mapi or third party libraries that side step the security issues.
Check out
http://www.slipstick.com/outlook/esecup.htm[^]
.............................
There's nothing like the sound of incoming rifle and mortar rounds to cure the blues. No matter how down you are, you take an active and immediate interest in life.
Fiat justitia, et ruat cælum
|
|
|
|
|
I need C# code to moderate e-mails.
If anybody has any simple code how to moderate e-mails,
I will appreciate if you will direct me to the site to download it.
Thanks.
A.Kwakye
|
|
|
|
|
What do you mean by "e-mail moderator"? I've never heard of it. I've heard of a moderating forum's posts though...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I assume you mean a spam filter. First your code needs to actually be running the mail server, then a simple reg-ex can be used to remove a lot of stuff.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Moderating emails is rather "vague". If you want a spam filter, there are many good solutions out there. If you want to block certain addresses, regardless of the "spam factor" (ex-girlfriends or so ).. you can have a mail relay tweaked. Postfix for example.
--
michael - www.code.ae
|
|
|
|
|
I need C# code to moderate e-maild.
If anybody has any simple code how to moderate e-mails,
I will appreciate if you will direct me to the site to download it.
Thanks.
A.Kwakye
|
|
|
|
|
Hi, all
I have designed an windows application in C#. I want to embed the plug-in functionality in it (like Winamp software), such that a third party can create a plug-in and can add its functionality to my application. How can I do it? What should I do extra on a simple Windows Application written in C#?
Thank you in advance.
Anindya Chatterjee
|
|
|
|
|
|
I'm confused on how to convert between enum types and integer types effeciently. Here's the code I'm working with:
public enum Rank
{
Hearts = 0, Diamonds = 1, Spades = 3, Clubs = 4
}
public enum Suit
{
Deuce = 0, Trey = 1, Four = 2, Five = 3, Six = 4, Seven = 5, Eight = 6,
Nine = 7, Ten = 8, Jack = 9, Queen = 10, King = 11, Ace = 12
}
Inside the card, the rank and suit are stored as:
Rank rank;
Suit suit;
The point being: I have a function shuffle which shuffles the deck using for loops.
public void Shuffle()
{
FillDeck();
Card tempCard = new Card();
Random rInt = new Random();
for (int i = 0; i < 100; i++)
{
int first = rInt.Next(51);
int second = rInt.Next(51);
// Copy deck[first] to tempCard
// Copy deck[second] to deck[first]
// Copy tempCard to deck[second]
tempCard.Set(deck[first].Rank, deck[first].Suit);
deck[first].Set(deck[second].Rank, deck[second].Suit);
deck[second].Set(tempCard.Rank, tempCard.Suit);
}
}
I'm attemping to pass integer values from the for loops into the Set function of card which takes Rank and Suit parameters. It's obviously causing errors.
Can I simply typecast an integer to the equivalent suit or rank like so without causing problems, and is it proper programming practice or is there a better way to do it?
tempCard.Set( (Rank)deck[first].Rank, (Suit)deck[first].Suit );
|
|
|
|
|
Whew, where to begin. First about the enums. I am assuming your Card class set method is structured as such: Card.Set ( Rank r, Suit s) and you have an array of Cards in deck[]. So to set your first card you would say deck[0].Set ( Rank.Hearts, Suit.Ace ).
Now the first problem is you have Rank and Suit mixed up, the Suit should be hearts, clubs, etc. Confusing to read.
Your second issue is your Card property Rank and Suit have the same name as your enum, that cannot be. I see what you are doing, you want to return that enum to set the next card with it, but you can't have the same name. I would change the name to CardRank and CardSuit and define the property like this:
//member variables
private Rank cardRank;
private Suit cardSuit;
//Properties
public Rank CardRank
{
set
{
cardRank = value;
}
get
{
return cardRank;
}
}
// do the same for CardSuit
now your swap functions will be:
tempCard.Set ( deck[first].CardRank, deck[first].CardSuit );
If you used integers in you Set function prototype then this won't work and you have to modify your properties to convert to integer or from integer depending on what your members are.
Your third issue is your last card will never get shuffled, Random returns a number less than the number passed in and your first and second could theoretcially be the same card (not a real problem, just wasted a shuffle)
If you want the integer value of an enum do this:
int x = (int) Rank.Clubs; //now x = 4
or
Rank r = Rank.Clubs;
int x = (int) r; //x = 4
finally if you want the string value:
string s = Rank.Clubs.ToString(); // s = "Clubs"
|
|
|
|
|
Awesome. Thanks for those pointers. That will certainly help me get sorted out.
There is one issue, the big one, that you didn't mention however (I don't think).
I have two integers from the four loops, s and r. s is between 0 and 3 and r is between 0 and 12. They correspond directly to the integer values I assigned the suits and ranks in the enum.
From those integers, I need to store the suit and rank, in the for loops.
So - I need to do something like:
Rank rank = (Rank)r; // r is in integer. if r == 12, then this should set rank equal to Rank.Ace, however, you can't typecast an integer to the equavalent enum value. I don't need the string. You see what I'm saying?
|
|
|
|
|
I just wrote my own static functions to do this, and added them to the card class:
public static Rank ConvertToRank(int i);
public static Suit ConvertToSuit(int i);
... just filled with switch statements to return the appropriote enum object.
I was hoping there was a better way to do this though.
|
|
|
|
|
In vb you can do
Dim r as Integer '<- Random rank
'Make r as random number
CardRank = CType(r, Rank)
I think in think in c# that would be
int r;
CardRank = (Rank)r;
But you say that doesn't work
Pretty weird...
Pompiedompiedom...
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
-- modified at 18:30 Thursday 27th October, 2005
|
|
|
|
|
In C# use the Enum static method ToObject
Suit myCard = (Suit) Enum.ToObject ( typeof ( Suit ), 12 );
This will set myCard to an ace (substitute the 12 for your integer you want the enum to be).
Hope that helps
|
|
|
|
|
Hello,
In the old C style, I could create a window whenever I desired.
Is there a wrapped way of creating windowses an child windowses in C# (not Forms or Controls), or I have to make lots of pInvokes?
I hope you understand...because is a rough world out there...
|
|
|
|