|
You can do this on a process level, not sure about thread level.
|
|
|
|
|
|
System.Diagnostics.Process.GetCurrentProcess().TotalProcessorTime
|
|
|
|
|
got my 4 rate,thanks
|
|
|
|
|
hi guys, I have a question, I want to know how I can store credentials(username, password) once they will be entered and if the user checks the checkbox that he wants to have them stored, so they will not care about typing again when they will visit again the app. It's not a web app, it's a desktop app. Thanks in advance
|
|
|
|
|
You could encrypt the data and then store it in the registry
And when the user signs in the next time just pick up the values from there and pass it to the Authentication system you are using
hope it helps
|
|
|
|
|
However you like. Registry/XML/app config/database/whatever
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
there are many ways to get your goal, store them to file, registry or configuration file(AppSettings), for example, you just store them to your configuration file, if the setting key is exist and its value not empty then use them as stored credential data, but you must encoded them for security purpose
dhaim
program is hobby that make some money as side effect
|
|
|
|
|
Write a file that contains this information and read it back in later on. This is consistent with the way that websites do it using cookies.
using (IsolatedStorage storage = IsolatedStorage.GetUserStorForDomain())
{
using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream("MySession.xml", FileMode.Create, storage)
{
fs.Close();
}
} To read it back in...
using (IsolatedStorage storage = IsolatedStorage.GetUserStorForDomain())
{
using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream("MySession.xml", FileMode.Open, storage)
{
fs.Close();
}
} The advantage of this method (using IsolatedStorage) is that it can only be read by the user/assembly that created it, and is completely Vista friendly.
|
|
|
|
|
freinds
can any body tell me how i can add child node to any existing root node
programetically.
wasim khan
|
|
|
|
|
The root node will have a collection of children you can add your node to. I suspect if you typed this question into google and added C# to it, you'd get plenty of great examples.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
either of these
treeView.Nodes[rootIndex].Nodes.Add(...);
treeView.Nodes[rootKey].Nodes.Add(...);
Dave
|
|
|
|
|
Hello Everyone,
I am trying to get a Type contained into a *.dll file, by means of System.Reflection.
After a long and painful Googling journey, I could see that the standard procedure to do this is:
Assembly theAssembly;
theAssembly = Assembly.LoadFrom("TheDll.dll");
Type theType = theAssembly.GetType("TheType");
I don't know if there's something wrong with my VS, my c# compiler or what... but this will NOT compile! First thing first, after I've declared theAssembly , I cannot access to its methods or properties through Intellisense. If I "force" the above piece of code, I get the Invalid token '=' in class, struct, or interface member declaration error on the '=' in the second line.
Am I doing something wrong?
Any help would be much appreciated.
Regards,
Rey9999
~~~ From Milano to The Hague, easy as it goes ~~~
|
|
|
|
|
Code compiles fine for me. Post the code for the whole class.
I suspect you're missing a close brace somewhere at the bottom.
Simon
|
|
|
|
|
I'd say you're missing a using System.Reflection at the top of this file.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi, thanks for the quick reply.
@Christian: I imported System.reflection, just did not copy here the whole code.
@Simon: I do not think it's something about braces, because if i do this:
Assembly theAssembly;
theAssembly = Assembly.LoadFrom("TheDll.dll");
Type theType = theAssembly.GetType("TheType");
I get the error, but if I do this:
Type theType = Assembly.LoadFrom("TheDll.dll").GetTypes()[0]
everything runs fine! and I did not change anything in the rest of the class. Any thought on this?
|
|
|
|
|
OK, I added the using statement and copied your code, it compiles just fine.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Jesus H. Christ, I was doing the dumbest and biggest mistake - the one you learn NOT to do on Programmers kindergarten, Day One.
I was trying to access the assembly outside of a method.
Thanks all the same. I just need to sleep more than 5 hours a night...
~~~ From Milano to The Hague, easy as it goes ~~~
|
|
|
|
|
This is a compiler error yeah?
post the code for the whole class, I'm sure you're missing something. maybe like a semi colon. You haven't got one at the end of your commented out line, so maybe you've got an extra on on a line below, so when you change the comments the semi colons are correct.
All the lines you've provided compile fine for me (I just had to add the semi colon to get the commented out line to compile).
Simon
|
|
|
|
|
Are you sure you write your code in the right place?
|
|
|
|
|
|
Nice one. we all make simple mistakes from time to time.
Simon
|
|
|
|
|
Hi friends,
My requirement is to maintain a collection of products based upon categories and i have to
retrieve that.For ex:i can retrieve different book names which are under the category Book..Say i
can retrieve all mobile company names which are under the category Mobile.I was told to use
collections here... What i suppose to do is to use list of arraylists...The list contains the
category(Book) and the arraylist under that list contains the products(All book names under book)
[List]------>[Array lists under the list]
[Book]----->[TamilBook][EnglisgBook][MathsBook]
[Mobiles]--->[Nokia][SonyEricson][Motorola]
I need code in C#.Net...Any known friends help me...
Thanks in advance....sherin
|
|
|
|
|
angelsherin wrote: What i suppose to do is to use list of arraylists
Sounds like a dumb idea. I'd use a dictionary/hashtable, then you can look up the collections directly. I'd never, ever use an arraylist or any other collection that's not strongly typed via generics.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
There's lots of ways of doing this. Firstly Arraylists are kind of considered old now. Instead you should use generics.
Personally, I would define a Product class, then have all products inherit from the product class, so Book would inherit from product and mobile would inherit from product etc.
Then have a List<Product> myList = new List<Product>() which can store all the products.
To get all products of certain types, you could use a Linq query.
(I'd never tried this with linq before, so I knocked up a quick test)
class Program
{
static void Main(string[] args)
{
List<product> myList = new List<product>();
myList.Add(new Book("Beginners C#", "Some author"));
myList.Add(new Book("Advanced C#", "Anon author"));
myList.Add(new Book("Expert gardening", "Mr Carrot"));
myList.Add(new Book("Step by step guide to plane building", "Mr S. Pitfire"));
myList.Add(new Mobile("Nokia N70", true, 3));
myList.Add(new Mobile("Sony W810", false,2));
var query = from b in myList
where b is Book
select b as Book;
foreach (Book book in query)
{
Console.WriteLine(book.ProductDescription + " by " + book.Author);
}
Console.ReadLine();
}
}
public class Product
{
private String _productDescription;
public Product(String productDescription)
{
_productDescription = productDescription;
}
public String ProductDescription
{
get
{
return _productDescription;
}
set
{
_productDescription = value;
}
}
}
public class Book : Product
{
private String _author;
public Book(String productDescription, String author)
: base(productDescription)
{
_author = author;
}
public String Author
{
get
{
return _author;
}
set
{
_author = value;
}
}
}
public class Mobile : Product
{
private bool _is3G;
private int _cameraMegaPixels;
public Mobile(String productDescription, bool is3G, int cameraMegaPixels)
: base(productDescription)
{
_is3G = is3G;
_cameraMegaPixels = cameraMegaPixels;
}
public int CameraMegaPixels
{
get
{
return _cameraMegaPixels;
}
set
{
_cameraMegaPixels = value;
}
}
public bool Is3G
{
get
{
return _is3G;
}
set
{
_is3G = value;
}
}
}
</product></product>
Simon
|
|
|
|