Hi All

I have just one question..

I have an application, at the login screen I have a check box where the user can select if he/she is the default user on the computer he/she is using.

What I would like to do is create a text file with the username in and when the application is started on the pc it calls that file and automatically assigns the default user (To make it user friendly :))

How would I go about to do this?

Recommended Answers

All 8 Replies

you could use the windows registry but i would just save it in a text or binary file

Member Avatar for Unhnd_Exception

You could also make a login field in your settings file to store it.

I read the article. Very interesting I must say, but that's not quite what I'm looking for. If I can save it in a text file, or perhaps indeed a login field it would be great, but how to go about and get started?

Any help plz??

Since you rejected the text file that is user and application settings, I'm not sure what it is that you want.

// Get the first line of a text file only
string userid = File.ReadAllLines("SomeFilePath")[0];

// Write a single line to a text file
File.WriteAllLines("SomeFilePath", new String[] {userid});

I read the article. Very interesting I must say, but that's not quite what I'm looking for. If I can save it in a text file, or perhaps indeed a login field it would be great, but how to go about and get started?

How are you trying to implement it then, if this isn't what you're looking for?

I read Momerath's quoted article and now have used settings in my own applications for the first time (with great success I should add too). Why can't you just have a defaultUser setting that stores the userid of the user? If you use user settings instead of application settings (as explained in the article above) all configurations are saved in a file called "User.config" which is just basically the text file you're looking for... I would think.

I found a solution. Thanks for all the help you guys :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.