Question Saving user input to a file?

cornfused

New member
Joined
Jun 10, 2010
Messages
2
Programming Experience
Beginner
This is my first asp.net page, apologies for poor code structure, etc.

All I want to do is ask the user for their name, and then store that name in a text file. I got this to run in Visual Web Developer 2008, and it stored the name in the text file as expected. When I put the same code on an IIS server, I got this error: "HRESULT: 0x800A004C (CTL_E_PATHNOTFOUND)"

Looking through event viewer, IIS logs, etc does not answer the question at hand -- what path? Where should I expect the file to be saved? Or, is there some method I should use to indicate where the file is to be saved?

Clues would be GREATLY appreciated.

VB.NET:
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Label1.Text = TextBox1.Text & ", welcome to the test web!"
        
        Dim objFSO, objTextFile As Object
        Const ForAppending As Integer = 8

        objFSO = CreateObject("Scripting.FileSystemObject")
        objTextFile = objFSO.OpenTextFile("guestbook.txt", ForAppending, True)
        objTextFile.WriteLine(TextBox1.Text)
        objTextFile.Close()
    End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <h1>Welcome to the test web server!</h1><br />
        <br />
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Submit" 
            onclick="Button1_Click" />
        <br />
        <asp:Label ID="Label1" runat="server" Text="Please type your name in the box above and press Submit."></asp:Label>
    </div>
    </form>
</body>
</html>
 
Thanks!

I had completely forgotten about 4guysfromrolla, I haven't visited that site in years.

I am going to rewrite my page and use their code as a jumping off point.

Thanks very much for your help!
 
Back
Top