Reading Files
-
Hi, I have the directory named NDP on my local machine (named PC4) which is in a domain. On my domain server, I have IIS 6.0 (windows 2003) and database server. I have the following sample code
protected void Button1_Click(object sender, EventArgs e) { Label1.Text = ""; DataTable dt = new DataTable(); StreamReader sr = new StreamReader(@"\\Pc4\C$\NDP\Test1.csv"); string line; while((line = sr.ReadLine()) != null) { Label1.Text += line; }
I have impersonate="true" in web.config file. The authentication mode is WIndows Integrated authentication. I have given permissions to ASPNET accounts and Windows accounts for the NDP folder. Can I read this .csv file? Because it is giving me error. I have also this code.protected void Page_Load(object sender, EventArgs e) { String username = System.Security.Principal.WindowsIdentity.GetCurrent().Name; Label1.Text = username; }
When executed it gives me the name of the user through which I have logged in but does not give access to my shared folder. Totally stumped. Any Solutions???:confused: -
Hi, I have the directory named NDP on my local machine (named PC4) which is in a domain. On my domain server, I have IIS 6.0 (windows 2003) and database server. I have the following sample code
protected void Button1_Click(object sender, EventArgs e) { Label1.Text = ""; DataTable dt = new DataTable(); StreamReader sr = new StreamReader(@"\\Pc4\C$\NDP\Test1.csv"); string line; while((line = sr.ReadLine()) != null) { Label1.Text += line; }
I have impersonate="true" in web.config file. The authentication mode is WIndows Integrated authentication. I have given permissions to ASPNET accounts and Windows accounts for the NDP folder. Can I read this .csv file? Because it is giving me error. I have also this code.protected void Page_Load(object sender, EventArgs e) { String username = System.Security.Principal.WindowsIdentity.GetCurrent().Name; Label1.Text = username; }
When executed it gives me the name of the user through which I have logged in but does not give access to my shared folder. Totally stumped. Any Solutions???:confused:It's not good idea to read the file from other machine in ASP.NET. What you should do is that you should create the web service that can copy the file from a particular machine (e.g. PC4 in your case) and upload those files to the service at specific time. then, read those files from your ASP.NET.
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)