473,466 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Run time errors with DataGrid

I am trying to create a guest book in a web application
and I keep getting the following runtime error:
Access to the
path "c:\inetpub\wwwroot\Guestbook\guestbook.txt" is
denied.

guestbook.txt is part of my solution so im not sure what
the problem is. Can anyone help me please. The code is
below: -
private void Page_Load(object sender, System.EventArgs e)
{
dataView = new DataView(new DataTable() );
}
public void FillMessageTable()
{
DataTable table = dataView.Table;
table.Columns.Add("Date");
table.Columns.Add("First Name");
table.Columns.Add("e-mail");
table.Columns.Add("Message");

//open guest book file for reading
StreamReader reader = new StreamReader(
Request.PhysicalApplicationPath +
"guestbook.txt");

char[] separator = {'\t'};
//read in line from file
string message = reader.ReadLine();

while (message != null)
{
//split the string into its four parts
string[] parts = message.Split(separator);

//load data into table
table.LoadDataRow(parts, true);

//read in one line from file
message = reader.ReadLine();
}

//update grid
dataGrid.DataSource = table;
dataGrid.DataBind();
reader.Close();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{

//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.clearbutton.Click += new System.EventHandler
(this.clearbutton_Click);
this.submitbutton.Click += new System.EventHandler
(this.submitbutton_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion

private void submitbutton_Click(object sender,
System.EventArgs e)
{
StreamWriter guestbook =
new StreamWriter(Request.PhysicalApplicationPath +
"guestbook.txt", true);

//write new message to file
guestbook.WriteLine(
DateTime.Now.Date.ToString().Substring(0, 10) +
"\t" + nameTextBox.Text + "\t" + emailTextBox.Text
+ "\t" + messageTextBox.Text );

//clear textboxes and close stream
nameTextBox.Text = "";
emailTextBox.Text = "";
messageTextBox.Text = "";
guestbook.Close();

FillMessageTable();
}
Nov 16 '05 #1
1 1457
On 09 Jul 2004 15:47, "Stephen Cairns" wrote:
I am trying to create a guest book in a web application
and I keep getting the following runtime error:
Access to the
path "c:\inetpub\wwwroot\Guestbook\guestbook.txt" is
denied.

guestbook.txt is part of my solution so im not sure what
the problem is. Can anyone help me please. The code is
below: -


Quite probably the user that ASP.NET is running as does not have permissions
to write to the file. Check the security on it (on the deployment machine)
and make sure that the ASP.NET process username is included.
--
Simon Smith
simon dot s at ghytred dot com
www.ghytred.com/NewsLook - NNTP Client for Outlook
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: SammyBar | last post by:
Hi, I'm trying to bind a custom collection class to a data grid, following the guidelines from the article http://msdn.microsoft.com/msdnmag/issues/05/08/CollectionsandDataBinding/default.aspx....
0
by: Dave | last post by:
Tried posting in the Winform Forum without much luck, so posting here... After inserting a new data row to a DataTable that is bound to a datagrid, I am unable to change data in a row that is...
4
by: Andrzej Wegrzyn | last post by:
Hi, I had a portal that worked before, and over 5 months period JavaScript errors started to show up on all forms where I have datagrids. Using: IE 6.0, WIN XP, IIS 5.1, Framework 1.1 ...
1
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a...
2
by: Kurt Schroeder | last post by:
Still new to code behind so i'm not sure what the problem is (i'm using visualStudio.net for the first time) like my last question i'll bet this has a quick answer. thanks kes here is the error:...
7
by: Brian Henry | last post by:
Ok how do I fix this... it worked in ASP.NET 1.1, in 2.0 it says Error 3 Option Strict On disallows implicit conversions from 'Object' to 'String'. here is the part of code it is giving this...
13
by: Douglas Buchanan | last post by:
I am using the following code instead of a very lengthly select case statement. (I have a lot of lookup tables in a settings form that are selected from a ListBox. The data adapters are given a...
4
by: Alan | last post by:
I keep getting an invalid cast error on this line of code: Dim gridCol As MyGridColumn = CType(dgt.GridColumnStyles(hi.Column), MyGridColumn) I am trying to develop a sub that will change the...
1
by: VanZandt | last post by:
I have a class(dll) that extends winform datagrid to provide link column in vb.net. I have managed to create a datagrid in c# winforms that shows link in one of the column but when I try to create a...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.