here i write content from main.aspx to file.txt file -
WebClient client2 = new WebClient();
using (Stream stream2 = client2.OpenRead("http://localhost/csharp/main.aspx")
{
using (StreamReader reader = new StreamReader(stream2, Encoding.Default))
{
string data = reader.ReadToEnd();
File.WriteAllText(GetLicenseFilePath(this.TemplateSourceDirectory),data, Encoding.Default);
}
}
private static string GetLicenseFilePath(string templateDirectory)
{
return Path.Combine(HttpContext.Current.Server.MapPath(templateDirectory), "file.txt");
}