Sometimes it's required to read Configuration File in the Silverlight Application.
The configuration file can be placed in the "ClientBin" folder and accessed from there.
In this function the "SLAppConfigURL" contains the configuration file name.
WebClient xmlClient = new WebClient();
xmlClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(xmlClient_DownloadStringCompleted);
xmlClient.DownloadStringAsync(new Uri(SLAppConfigURL, UriKind.RelativeOrAbsolute));
}
Once the configuration file is read, the program control comes to the below function. The entire file content will be in the "e.Result" varaible. You can deserialize it or read from the string directly at this point.
string xmlConfig = e.Result;
}
Happy Coding.
Cheers
Anand
The configuration file can be placed in the "ClientBin" folder and accessed from there.
In this function the "SLAppConfigURL" contains the configuration file name.
private void
GetConfigData()
{WebClient xmlClient = new WebClient();
xmlClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(xmlClient_DownloadStringCompleted);
xmlClient.DownloadStringAsync(new Uri(SLAppConfigURL, UriKind.RelativeOrAbsolute));
}
void xmlClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs
e)
{string xmlConfig = e.Result;
}
Happy Coding.
Cheers
Anand