Thursday, September 2, 2010

How to Append Image path to Text File using C#

by Emmaneale Mendu, Web Developer


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
<title>Image Button Example</title>
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />



using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;

public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)

protected void Button1_Click(object sender, EventArgs e)
String FileName = Server.MapPath("Output.txt");

StreamWriter objStreamWriter;
objStreamWriter = File.AppendText(FileName);

String imagepath = Html32TextWriter.DoubleQuoteChar + "desibindaas.jpg"
+ Html32TextWriter.DoubleQuoteChar;

objStreamWriter.WriteLine("<img src=" + imagepath + " alt=" + Html32TextWriter.DoubleQuoteChar
+ "Emmu Image" + Html32TextWriter.DoubleQuoteChar + " /><br/>");


StreamReader objStreamReader;
objStreamReader = File.OpenText(FileName);

String contents = objStreamReader.ReadToEnd();

No comments:

Post a Comment