المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Set an arrays items to new strings



C# Programming
06-09-2009, 04:51 AM
Humm this is a puzzler im settings from a .txt file which looks like this

//This is the directory which your downloaded files will be stored in
DownloadFolder = /mnt/md1/public/Downloads

//The telnet user usualy root
TelnetUser = root

//The telnet password
TelnetPassword = root

//The IP of your NAS eg 192.168.2.2
TelnetIP = 192.168.2.2

I want to convert these values into strings eg TelnetIP = 192.168.2.2 so they can be reused on multiple forms . So ive got them importing with a StreamReader below



private void LoadSettings()
{
StreamReader Settings = new StreamReader("Settings.txt");
string line;
while ((line = Settings.ReadLine()) != null)
{
if (line.StartsWith("/"))
{
}
else
{
string[] splitArray = line.Split(new char[] { '=' });
MessageBox.Show(splitArray[0]);

}
}

}


So in this case splitArray[0] gives DownloadFolder and splitArray[1] gives /mnt/md1/public/Downloads perfect but how do i join them back togeather to give

DownloadFolder = /mnt/md1/public/Downloads

And also im getteng blank lines coming through as settings else if (line.StartsWith("/r/n")) or \r\n dosnt seem to catch them

any ideas ? thanks