I’m trying to run this;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DosyadanOku("c:\\sucdefteri.txt");
Console.ReadLine();
}
public void DosyadanOku(string sucdefteri)
{
StreamReader dosyaOku = new StreamReader(@"C:\\sucdefteri.txt");
string metin;
metin = dosyaOku.ReadLine();
string kesme = "\t";
char[] b = kesme.ToCharArray();
string[] satirlar = metin.Split(b);
Page.ClientScript.RegisterArrayDeclaration("Skills", satirlar[2]);
dosyaOku.Close();
}
}
at my server side of ASP.net page. This simply gets a line from sucdefteri.txt, then cuts a part of it and passes it to client side of page with
Page.ClientScript.RegisterArrayDeclaration(“Skills”, satirlar[2]);. I mean it should, but it can’t. If I try this file reading/cutting code as a console application, it’s working fine, getting the part from the line and print it to console. But it’s not working with this. And also if I add a code like this;
satirlar[2] ="'izmit'";
and then send it to client, it’s working. So I think something is wrong with the file reading.
Thank you for your helps.
use
Server.MapPath(" ")like this