Hi,
Can anyone help me?
I have two text boxes, one single-line and one multiline.
I wish to save the text within the multiline textbox as a txt file,
with a file name by the text in the single-line textbox.
Does that make sense?
If the single-line textbox is 'helpme', I wish to create a txt file of the
multiline textbox called helpme.txt
I have found cound so far as follows, but this only adds text from a textbox
to an existing file.
<%@ Import Namespace="Syst em.IO" %>
<Script Runat="Server">
Sub Button_Click( s As Object, e As EventArgs )
Dim objStreamWriter As StreamWriter
objStreamWriter = File.CreateText ( MapPath( "myFile.txt " ) )
objStreamWriter .WriteLine( txtInput.Text )
objStreamWriter .Close
End Sub
</Script>
Can anyone help please?
Paul Evans 2 4945
First, it is bad design practice to allow a user to submit data that
will be used in a filename path. This opens the door for attacks on your
system.
But, I'd imagine you'd want to change this line to the following:
objStreamWriter = File.CreateText ( MapPath( SingleLineTextB ox.Text &
".txt" ) )
That should work, but again that is extremely bad design practice.
Lowell
Paul Evans wrote: Hi,
Can anyone help me?
I have two text boxes, one single-line and one multiline. I wish to save the text within the multiline textbox as a txt file, with a file name by the text in the single-line textbox.
Does that make sense? If the single-line textbox is 'helpme', I wish to create a txt file of the multiline textbox called helpme.txt
I have found cound so far as follows, but this only adds text from a textbox to an existing file.
<%@ Import Namespace="Syst em.IO" %>
<Script Runat="Server">
Sub Button_Click( s As Object, e As EventArgs ) Dim objStreamWriter As StreamWriter
objStreamWriter = File.CreateText ( MapPath( "myFile.txt " ) ) objStreamWriter .WriteLine( txtInput.Text ) objStreamWriter .Close End Sub
</Script> Can anyone help please?
Paul Evans
check out: http://aspnet101.com/aspnet101/aspne...ode=createText
David Wier
MCP, MVP ASP.NET, ASPInsider http://aspnet101.com http://aspexpress.com
Coming Soon - Data Management Toolkit
Manage MSDE/SQL Server/MySQL/MS Access Databases from one location. http://augustwind.com/augustwind/dmt.aspx
"Paul Evans" <pa*********@bt internet.com> wrote in message
news:OM******** ********@TK2MSF TNGP15.phx.gbl. .. Hi,
Can anyone help me?
I have two text boxes, one single-line and one multiline. I wish to save the text within the multiline textbox as a txt file, with a file name by the text in the single-line textbox.
Does that make sense? If the single-line textbox is 'helpme', I wish to create a txt file of the multiline textbox called helpme.txt
I have found cound so far as follows, but this only adds text from a
textbox to an existing file.
<%@ Import Namespace="Syst em.IO" %>
<Script Runat="Server">
Sub Button_Click( s As Object, e As EventArgs ) Dim objStreamWriter As StreamWriter
objStreamWriter = File.CreateText ( MapPath( "myFile.txt " ) ) objStreamWriter .WriteLine( txtInput.Text ) objStreamWriter .Close End Sub
</Script> Can anyone help please?
Paul Evans
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: steve |
last post by:
Hello,
I am trying to import an image file into a form. This would be a
persons picture saved in the same directory for every unique record.
I don't have any problems making an action button to open the
directory where the images are but I am having problems putting the
images in the form and also linking a field in a table to this image.
I would rather not have the images saved in access2000 but simple
linked to the file in the directory...
|
by: Ruy Castelli |
last post by:
I created a ASP.NET page using C# and I'm using two components to access a
MS-Access database, which are:
- oleDbConnection
- oleDataAdapter
The MS-Access database is in the correct directory, IIS has permission to
write. Everything seems ok, but IIS says that it can't open the file because
there is someone else using it exclusively (impossible, I'm using a stand
alone computer and I closed everything) or I need permission to open the
|
by: Nikhil Patel |
last post by:
Hi,
I bind a grid to a DataView object. I lose the reference to the underlying
DataTable and the DataSet in a postback.
Here is the code. Page_Load works fine and I am able to see the rows in grid
and edit them. But I don't know how to save the data back to the database
when the user clicks on a Button. Thanks.
private void Page_Load(object sender, System.EventArgs e)
{
|
by: Ruy Castelli |
last post by:
I created a ASP.NET page using C# and I'm using two components to access a
MS-Access database, which are:
- oleDbConnection
- oleDataAdapter
The MS-Access database is in the correct directory (IIS has permission to
read/write) and everything seems ok, but IIS says that it can't open the
file because there is someone else using it exclusively (impossible, I'm
using a stand alone computer and I closed everything) or I need permission
|
by: AxOn |
last post by:
Hi! I'm having trouble creating a save funktion. How can I save the
contens of a new richTextBox that is created from an "external" class
file? The open funktion looks like this:
public void openFile()
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Title = "Select a Text File";
| |
by: Gregaz |
last post by:
I have a form in my project, which I open as a DialogBox. On that that
form there are 3 TextBoxes. To one of them I want to write in a file
path. To have it easier I have an OpenFileDialog control on my form.
Selected file path is written in to th TextBox. OpenFileDialog is open
by click on a Button.
There is other Button on the form run the code which save every form
field to a file.
When I manualy fill all fields in form everything...
|
by: Pedro Leite |
last post by:
Good Afternoon.
the code below is properly retreiving binary data from a database and saving
it. but instead of saving at client machine is saving at the server machine.
what is wrong with my code ??
thank you
Pedro Leite From Portugal
------------------------------------
|
by: toddw607 |
last post by:
Hi all!
I am attempting to bring an SQL Server table into ASP.NET using the datagrid . I have set all cells to be a text box by which the user can just click on and edit the cell. I have a save button and when I click the save button the page reloads and the new data is in the cell, however when I close out and come back in the data is no longer there. I have a databind() subroutine which includes a postback included within my code for...
|
by: romcab |
last post by:
Hi guys,
I would like to ask your help about saving in ado.net. I was able to update it only on the display but when I check the database, it is not updated. I paste below my code and hopefully you can help me.
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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 we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |