7 Replies - 1231 Views - Last Post: 06 November 2010 - 05:51 PM Rate Topic: -----

#1 SourLemons  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 65
  • Joined: 02-August 10

Store an information in the application?

Posted 06 November 2010 - 08:59 AM

How to add a custom string in the application so that it can remember it?

• User’s custom passwords.
• Trial periods

To be more specific on what do i want..

• I want user to set a password for my application.
• It is a screen locker and let the users to set a password for the locker.
• The application then remembers the password set by user.
• I've a small sized video and a pic,as an explanation of what i meant.

Posted Image



Thank You.

Is This A Good Question/Topic? 0
  • +

Replies To: Store an information in the application?

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5519
  • View blog
  • Posts: 11,827
  • Joined: 02-June 10

Re: Store an information in the application?

Posted 06 November 2010 - 09:52 AM

Quote

How do I design my entire application?


You know the drill here. We won't do your school homework for you. You have to make a good faith effort to code this on your own, then provide specific code to specific issues you need help with.


I agree we are happy to help. Sometimes the best help is examples. Sometimes its solving the problem. Sometimes its pointing toward some good resources.

I am going to guess that you are trying to teach yourself C# without much guidance, a decent book or without knowing where to look. Sometimes just knowing where to look can make all the difference. Google is your friend.
Search with either "C#" or "MSDN" as the first word: "MSDN Picturebox", "C# Custom Events", "MSDN timer" etc.

But honestly, just typing away and seeing what pops up in Intellisense is going to make your self-education take 20 years. You can learn by trying to reverse engineer the language through banging on the keyboard - or you can learn by doing the tutorials and following a good "How to learn C#" book.

May I suggest picking up a basic C# introductory book? It's not that people here don't want to be helpful, but there is a certain amount of basic learning work that one should really take upon themselves before asking for help. There are so many great "How do I build my first application" tutorials on the web... There are dozens of "Learn C# in 21 days", "My first C# program" books at your local book seller or even public library... Asking a forum, any forum, to hand-hold you through it is just redundant. In many ways it disrespects the people who have invested dozens of hours in the on-line tutorials and those that spent thousands of hours in authoring books.

Build a Program Now! in Visual C# by Microsoft Press, ISBN 0-7356-2542-5
is a terrific book that has you build a Windows Forms application, a WPF app, a database application, your own web browser.

C# Cookbooks
Are a great place to get good code, broken down by need, written by coding professionals. You can use the code as-is, but take the time to actually study it. These professionals write in a certain style for a reason developed by years of experience and heartache.

Microsoft Visual Studio Tip, 251 ways to improve your productivity, Microsoft press, ISBN 0-7356-2640-5
Has many, many great, real-world tips that I use all the time.

The tutorials below walk through making an application including inheritance, custom events and custom controls.
Quick and easy custom events
Bulding an application - Part 1
Building an application - Part 2
Debugging tutorial
Working with environmental variables

Writing a text file is always one of the first things people want to do, in order to store data like high-scores, preferences and so on
Writing a text file tutorial.

These are just good every-day references to put in your bookmarks.
MSDN C# Developers Center with tutorials
Welcome to Visual Studio

Have you seen the MSDN Code Samples? They spent a lot of time creating samples and demos. It seems a shame to not use them.

  • Anonymous Delegates: Demonstrates the use of unnamed delegates to reduce application complexity.
  • Arrays: Shows how to use arrays.
  • Attributes: Shows how to create custom attribute classes, use them in code, and query them through reflection.
  • Collection Classes: Shows how to make non-generic collection classes that can be used with the foreach statement.
  • COM Interop Part I: Shows how to use C# to interoperate with COM objects.
  • COM Interop Part II: Shows how to a use a C# server together with a C++ COM client.
  • Commandline: Demonstrates simple command-line processing and array indexing.
  • Condiational Methods: Demonstrates conditional methods, which provide a powerful mechanism by which calls to methods can be included or omitted depending on whether a symbol is defined.
  • Delegates: Shows how delegates are declared, mapped to static and instance methods, and combined into multicast delegates.
  • Events: Shows how to declare, invoke, and configure events in C#.
  • Explicit Interface: Demonstrates how to explicitly implement interface members and how to access those members from interface instances.
  • Generics: Shows how to make generic collection classes that can be used with the foreach statement.
  • Hello World: A Hello World application.
  • Indexers Part I: Shows how C# classes can declare indexers to provide array-like access to objects.
  • Indexers Part II: Shows how to implement a class that uses indexed properties. Indexed properties enable you to use a class that represents an array-like collection.
  • Libraries: Shows how to use compiler options to create a DLL from multiple source files; also, how to use the library in other programs
  • Named and Optional (C# 4.0): Demonstrates Named and Optional parameters, an alternative to method overloads
  • Nullable: Demonstrates value types, such as double and bool, that can be set to null
  • Office Sample (C# 4.0): Demonstrates how Dynamic and COM Interop make it easy to call Microsoft Office in C# 4.0
  • OLEDB: Demonstrates how to use a Microsoft Access database from C# by creating a dataset and adding tables to it.
  • Operator Overloading: Shows how user-defined classes can overload operators
  • Partial Types: Demonstrates how classes and structures can be defined in multiple C# source-code files
  • PInvoke: Shows how to call exported DLL functions from C#
  • Properties: Shows how properties are declared and used; also demonstrates abstract properties
  • Python Sample (C# 4.0): Learn how to call a Python script by using the Dynamic feature in C# 4.0
  • Security: Discusses .NET Framework security and shows how to modify security permissions in C# by using permission classes and permission attributes
  • Simple Variance (C# 4.0): See how Covariance and Contravariance are supported in generic interfaces and delegates
  • Structs: Shows how to use structs in C#.
  • Threading: Demonstrates various thread activities such as creating and executing a thread, synchronizing threads, interacting between threads, and using a thread pool
  • Unsafe: Shows how to use unmanaged code (code that uses pointers) in C#
  • User Conversions: Shows how to define conversions to and from user-defined types
  • Versioning: Demonstrates versioning in C# by using the override and new keywords
  • XML Documents: Shows how to document code by using XML
  • Yield: Demonstrates how to use the yield keyword to filter items in a collection

Was This Post Helpful? 0
  • +
  • -

#3 SourLemons  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 65
  • Joined: 02-August 10

Re: Store an information in the application?

Posted 06 November 2010 - 10:11 AM

Quote

You know the drill here. We won't do your school homework for you. You have to make a good faith effort to code this on your own, then provide specific code to specific issues you need help with.


_With your due respect, I ain't doing any homeworks nor any specific work. I am doing a self study.

And i just wanted to ask for help and its "pretty much" specific.

* Well if u don't wanna help,it's alright and i am fine with it.

* I just don't want u to be posting this thing whenever someone asks for help and it's already specific, not to be rude.

* I've stacks of licensed ebooks and reading materials, I guess you do also agree with me that only understanding thru letters and notes are for geniuses only, and not for beginners like us.

* I appreciate you posting those things and I know it's important, still "It's not too good for ppl who are asking ya an specific question."

* We learners have high expectations to obtain help from high std members like ya all. If you didn't know that then you may know it too.

* We, here "I" am not asking for you to do the whole thing, I am just asking where can i get to know "how to store information in app like
passwords and login's?"

* Also, I've seen a lot of replies in unfamiliar posts about homework crap, and if you think the same about me then you are wrong.
I ain't a loser who asks for help in my homework, and never asked for help about my hw.

* Either way, there's Google you may say. " People's best friend - Google. " Don't say i didn't try it, i searched alot, i can't find the one specific which i was tryin' to know about.

_ It's not my rudeness or talkin' behavior, I am just saying what we, learners feel like and their intentions.


So, I am totally ignoring this quoted thing:

Quote

I am going to guess that you are trying to teach yourself C# without much guidance, a decent book or without knowing where to look. Sometimes just knowing where to look can make all the difference. Google is your friend.
Search with either "C#" or "MSDN" as the first word: "MSDN Picturebox", "C# Custom Events", "MSDN timer" etc.

But honestly, just typing away and seeing what pops up in Intellisense is going to make your self-education take 20 years. You can learn by trying to reverse engineer the language through banging on the keyboard - or you can learn by doing the tutorials and following a good "How to learn C#" book.

May I suggest picking up a basic C# introductory book? It's not that people here don't want to be helpful, but there is a certain amount of basic learning work that one should really take upon themselves before asking for help. There are so many great "How do I build my first application" tutorials on the web... There are dozens of "Learn C# in 21 days", "My first C# program" books at your local book seller or even public library... Asking a forum, any forum, to hand-hold you through it is just redundant. In many ways it disrespects the people who have invested dozens of hours in the on-line tutorials and those that spent thousands of hours in authoring books.

Build a Program Now! in Visual C# by Microsoft Press, ISBN 0-7356-2542-5
is a terrific book that has you build a Windows Forms application, a WPF app, a database application, your own web browser.

C# Cookbooks
Are a great place to get good code, broken down by need, written by coding professionals. You can use the code as-is, but take the time to actually study it. These professionals write in a certain style for a reason developed by years of experience and heartache.

Microsoft Visual Studio Tip, 251 ways to improve your productivity, Microsoft press, ISBN 0-7356-2640-5
Has many, many great, real-world tips that I use all the time.

The tutorials below walk through making an application including inheritance, custom events and custom controls.
Quick and easy custom events
Bulding an application - Part 1
Building an application - Part 2
Debugging tutorial
Working with environmental variables

Writing a text file is always one of the first things people want to do, in order to store data like high-scores, preferences and so on
Writing a text file tutorial.

These are just good every-day references to put in your bookmarks.
MSDN C# Developers Center with tutorials
Welcome to Visual Studio

Have you seen the MSDN Code Samples? They spent a lot of time creating samples and demos. It seems a shame to not use them.

* Anonymous Delegates: Demonstrates the use of unnamed delegates to reduce application complexity.
* Arrays: Shows how to use arrays.
* Attributes: Shows how to create custom attribute classes, use them in code, and query them through reflection.
* Collection Classes: Shows how to make non-generic collection classes that can be used with the foreach statement.
* COM Interop Part I: Shows how to use C# to interoperate with COM objects.
* COM Interop Part II: Shows how to a use a C# server together with a C++ COM client.
* Commandline: Demonstrates simple command-line processing and array indexing.
* Condiational Methods: Demonstrates conditional methods, which provide a powerful mechanism by which calls to methods can be included or omitted depending on whether a symbol is defined.
* Delegates: Shows how delegates are declared, mapped to static and instance methods, and combined into multicast delegates.
* Events: Shows how to declare, invoke, and configure events in C#.
* Explicit Interface: Demonstrates how to explicitly implement interface members and how to access those members from interface instances.
* Generics: Shows how to make generic collection classes that can be used with the foreach statement.
* Hello World: A Hello World application.
* Indexers Part I: Shows how C# classes can declare indexers to provide array-like access to objects.
* Indexers Part II: Shows how to implement a class that uses indexed properties. Indexed properties enable you to use a class that represents an array-like collection.
* Libraries: Shows how to use compiler options to create a DLL from multiple source files; also, how to use the library in other programs
* Named and Optional (C# 4.0): Demonstrates Named and Optional parameters, an alternative to method overloads
* Nullable: Demonstrates value types, such as double and bool, that can be set to null
* Office Sample (C# 4.0): Demonstrates how Dynamic and COM Interop make it easy to call Microsoft Office in C# 4.0
* OLEDB: Demonstrates how to use a Microsoft Access database from C# by creating a dataset and adding tables to it.
* Operator Overloading: Shows how user-defined classes can overload operators
* Partial Types: Demonstrates how classes and structures can be defined in multiple C# source-code files
* PInvoke: Shows how to call exported DLL functions from C#
* Properties: Shows how properties are declared and used; also demonstrates abstract properties
* Python Sample (C# 4.0): Learn how to call a Python script by using the Dynamic feature in C# 4.0
* Security: Discusses .NET Framework security and shows how to modify security permissions in C# by using permission classes and permission attributes
* Simple Variance (C# 4.0): See how Covariance and Contravariance are supported in generic interfaces and delegates
* Structs: Shows how to use structs in C#.
* Threading: Demonstrates various thread activities such as creating and executing a thread, synchronizing threads, interacting between threads, and using a thread pool
* Unsafe: Shows how to use unmanaged code (code that uses pointers) in C#
* User Conversions: Shows how to define conversions to and from user-defined types
* Versioning: Demonstrates versioning in C# by using the override and new keywords
* XML Documents: Shows how to document code by using XML
* Yield: Demonstrates how to use the yield keyword to filter items in a collection

Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5519
  • View blog
  • Posts: 11,827
  • Joined: 02-June 10

Re: Store an information in the application?

Posted 06 November 2010 - 10:50 AM

Quote

I want user to set a password for my application.

That would be a variable inside your code. string UserPass = "password123";

Quote

I want user to set a password for my application.

You could store it in a text file, an XML file, or the registry. I would recommend encrypting it.
You could have unique serial numbers for each build and keep a repository on your own web server.
You could require the user to use a USB dongle to store their preferences and use it like a digital key to their computer.

Quote

Trial periods

That's it. Not a question. Not anything but those two words. What is anyone here supposed to take away from that?
A: internet time server.


Regarding your response to my comments:
1) You can say all you want about a noobie's expectations. But the DIC site has their expectations posted and they include the poster show a good faith effort to code their program. Frankly you showed no effort to do this. You posted video of someone else's work then asked "Can someone help me reverse engineer this behavior?" Honestly you're lucky one of the admins didn't just delete the post altogether because that is what usually happens to posts where someone doesn't show a good faith effort. Just to be fair: You made virtually no effort on your own question so why would you expect anyone to take you seriously enough to put in a big effort on the response?

Quote

How to add a custom string in the application so that it can remember it?

2) You say you have many coding books. Have you read them? I don't mean 'Did you look in the table of contents for something that sounded close to *this* need?" I mean "Have you read your coding books cover to cover?" Because if you had then at least some of the key words and concepts should have stuck in your head and you would at least think to yourself 'I remember a couple of these talking about Application Settings. I didn't have a need at the time, but now that might come into use.' I'm sure at least one of them takes about Application Settings. Or how to store values, whether it be game high scores, or vehicle makes and models, or student names and grades.

3) I'll just copy in my standard response to extensive use of u, ppl, and so on


Also, dis not b d'hood dawg... You are not here texting your high school posse to come to your kegger after their shift at Taco Bell. You are here asking for help from senior coding professionals who graciously donate their valuable time to helping the next generation of coders with their chosen craft. Please try to show them, yourself and the industry some respect by writing at least at an eighth grade level. (IE: English not ebonics or SMS, real words, punctuation and so on)

If you can't take your own problem/question seriously enough to write like an adult, then why would you expect anyone else to take it seriously?
Was This Post Helpful? 0
  • +
  • -

#5 SourLemons  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 65
  • Joined: 02-August 10

Re: Store an information in the application?

Posted 06 November 2010 - 11:30 AM

Quote

View PosttlhIn, on 06 November 2010 - 09:50 AM, said:

Quote

I want user to set a password for my application.

That would be a variable inside your code. string UserPass = "password123";

Quote

I want user to set a password for my application.

You could store it in a text file, an XML file, or the registry. I would recommend encrypting it.
You could have unique serial numbers for each build and keep a repository on your own web server.
You could require the user to use a USB dongle to store their preferences and use it like a digital key to their computer.


_Yea, Thanks for this much. I appreciate you helping me with a little bit of related words.

* I'll search it on the internet or my own ebooks.

Ignored:

Quote

Trial periods

That's it. Not a question. Not anything but those two words. What is anyone here supposed to take away from that?
A: internet time server.


Regarding your response to my comments:
1) You can say all you want about a noobie's expectations. But the DIC site has their expectations posted and they include the poster show a good faith effort to code their program. Frankly you showed no effort to do this. You posted video of someone else's work then asked "Can someone help me reverse engineer this behavior?" Honestly you're lucky one of the admins didn't just delete the post altogether because that is what usually happens to posts where someone doesn't show a good faith effort. Just to be fair: You made virtually no effort on your own question so why would you expect anyone to take you seriously enough to put in a big effort on the response?

Quote

How to add a custom string in the application so that it can remember it?

2) You say you have many coding books. Have you read them? I don't mean 'Did you look in the table of contents for something that sounded close to *this* need?" I mean "Have you read your coding books cover to cover?" Because if you had then at least some of the key words and concepts should have stuck in your head and you would at least think to yourself 'I remember a couple of these talking about Application Settings. I didn't have a need at the time, but now that might come into use.' I'm sure at least one of them takes about Application Settings. Or how to store values, whether it be game high scores, or vehicle makes and models, or student names and grades.

3) I'll just copy in my standard response to extensive use of u, ppl, and so on


Also, dis not b d'hood dawg... You are not here texting your high school posse to come to your kegger after their shift at Taco Bell. You are here asking for help from senior coding professionals who graciously donate their valuable time to helping the next generation of coders with their chosen craft. Please try to show them, yourself and the industry some respect by writing at least at an eighth grade level. (IE: English not ebonics or SMS, real words, punctuation and so on)

If you can't take your own problem/question seriously enough to write like an adult, then why would you expect anyone else to take it seriously?


_It's not that I can finish reading all the books and i ain't doing a surface study. I am studying the books and my school works too. I need to balance them all. Also, i wonder if you could properly write a "SPECIFIC Words about programming" at age 13-14.I've read about the xml and .txt storage for game scores and web updates in xml, but mine's not related with that.

I want my app to store "password" not high score infos, if the .txt can be seen and edited, what's the use of making my app password protected?

Thanks anyways. Can't ignore a person who helped me so much.

This post has been edited by SourLemons: 06 November 2010 - 11:33 AM

Was This Post Helpful? 0
  • +
  • -

#6 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5519
  • View blog
  • Posts: 11,827
  • Joined: 02-June 10

Re: Store an information in the application?

Posted 06 November 2010 - 02:30 PM

Quote

I've read about the xml and .txt storage for game scores and web updates in xml, but mine's not related with that.

I want my app to store "password" not high score infos, if the .txt can be seen and edited, what's the use of making my app password protected?

Thanks anyways. Can't ignore a person who helped me so much.


Data is data. Whether it is a password or the price of a car or a student's grades or a game high score. The computer does'nt know the differrence. You still write your text/XML/registry in exactly the same way. A string is a string.

As I said, you probably want to encrypt your password before you write it so it is not plain-text. Earlier in this thread you decided you were going to ignore all of it. If you had taken the suggestion of googling with the terms "MSDN" plus what you are looking for then "MSDN encryption" would have gotten you this example of encrypting a file:
http://support.microsoft.com/kb/307010

Quote

I need to balance them all.
Don't think it gets any easier. Everyone has to balance all the aspects of their life. Work, hobbies, school, family. I think it is great that you are getting into this at 13-14 years old. I got my first Commodore computer about that same age. Only that was before the internet made it easy to research. Just remember that pressures and priorities only get harder from this age, not easier.
Was This Post Helpful? 0
  • +
  • -

#7 SourLemons  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 65
  • Joined: 02-August 10

Re: Store an information in the application?

Posted 06 November 2010 - 04:20 PM

Quote

Don't think it gets any easier. Everyone has to balance all the aspects of their life. Work, hobbies, school, family. I think it is great that you are getting into this at 13-14 years old. I got my first Commodore computer about that same age. Only that was before the internet made it easy to research. Just remember that pressures and priorities only get harder from this age, not easier.


_I know right. We students work hard to pile up GPA to get into a good college. I am called a book-worm among my friends. :whatsthat: Everyone's life is running this way, why not mine? :bigsmile: ( Simple living, great thinking? ;D )

Thanks.
Was This Post Helpful? 0
  • +
  • -

#8 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1253
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: Store an information in the application?

Posted 06 November 2010 - 05:51 PM

Look into the System.Configuration namespace.

Basically the app.config file lets you save key/value pairs. So you'd save a value "mypassword123" to the key "password".

Then in code you could call it with:

System.ConfigurationManager["password"]

Google that namespace and you'll see results. Or check my blog for a complete tutorial on using it.

Then there's the matter of the password being visible in plaintext. Easy, just encrypt it using a salt + hash and THEN save it to the app.config file.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1