473,387 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

save/open

I am trying to get the save/open dialog figured out. I am able open the save
dialog but when I put in a file name (whatever.txt) and save the file does
save with the name but it is blank. Below is what I have code so far.

Dim phonestreamwriter As StreamWriter
Dim responsedialogresults As DialogResult
SaveFileDialog1.InitialDirectory = Application.StartupPath
responsedialogresults = SaveFileDialog1.ShowDialog
If responsedialogresults <> DialogResult.Cancel Then
phonestreamwriter = New StreamWriter(SaveFileDialog1.FileName)
End If

Jul 21 '05 #1
3 1949
You open the StreamWriter which creates the file, but you also have to write
something to it. For example, if you added the following line after you
create the StreamWriter:

phonestreamwriter.WriteLine("Hello, world")
phonestreamwriter.Flush()
phonestreamwriter.Close()

the underlying file would have the content "Hello, world" inside the file.

You have to define what is supposed to go into the file. The save/open
dialog is only used to query the user for the file path.

--
Ben Lucas
Lead Developer
Solien Technology, Inc.
www.solien.com

"Newbie" <Ne****@discussions.microsoft.com> wrote in message
news:DB**********************************@microsof t.com...
I am trying to get the save/open dialog figured out. I am able open the save dialog but when I put in a file name (whatever.txt) and save the file does
save with the name but it is blank. Below is what I have code so far.

Dim phonestreamwriter As StreamWriter
Dim responsedialogresults As DialogResult
SaveFileDialog1.InitialDirectory = Application.StartupPath
responsedialogresults = SaveFileDialog1.ShowDialog
If responsedialogresults <> DialogResult.Cancel Then
phonestreamwriter = New StreamWriter(SaveFileDialog1.FileName)
End If

Jul 21 '05 #2
If I have text in a rich text on a form how do I write that to the file

RichTextBox1.Text = SaveFileDialog1.FileName????

"Ben Lucas" wrote:
You open the StreamWriter which creates the file, but you also have to write
something to it. For example, if you added the following line after you
create the StreamWriter:

phonestreamwriter.WriteLine("Hello, world")
phonestreamwriter.Flush()
phonestreamwriter.Close()

the underlying file would have the content "Hello, world" inside the file.

You have to define what is supposed to go into the file. The save/open
dialog is only used to query the user for the file path.

--
Ben Lucas
Lead Developer
Solien Technology, Inc.
www.solien.com

"Newbie" <Ne****@discussions.microsoft.com> wrote in message
news:DB**********************************@microsof t.com...
I am trying to get the save/open dialog figured out. I am able open the

save
dialog but when I put in a file name (whatever.txt) and save the file does
save with the name but it is blank. Below is what I have code so far.

Dim phonestreamwriter As StreamWriter
Dim responsedialogresults As DialogResult
SaveFileDialog1.InitialDirectory = Application.StartupPath
responsedialogresults = SaveFileDialog1.ShowDialog
If responsedialogresults <> DialogResult.Cancel Then
phonestreamwriter = New StreamWriter(SaveFileDialog1.FileName)
End If


Jul 21 '05 #3
phonestreamwriter.WriteLine(RichTextBox1.Text)

"Newbie" <Ne****@discussions.microsoft.com> wrote in message
news:D8**********************************@microsof t.com...
If I have text in a rich text on a form how do I write that to the file

RichTextBox1.Text = SaveFileDialog1.FileName????

"Ben Lucas" wrote:
You open the StreamWriter which creates the file, but you also have to write something to it. For example, if you added the following line after you
create the StreamWriter:

phonestreamwriter.WriteLine("Hello, world")
phonestreamwriter.Flush()
phonestreamwriter.Close()

the underlying file would have the content "Hello, world" inside the file.
You have to define what is supposed to go into the file. The save/open
dialog is only used to query the user for the file path.

--
Ben Lucas
Lead Developer
Solien Technology, Inc.
www.solien.com

"Newbie" <Ne****@discussions.microsoft.com> wrote in message
news:DB**********************************@microsof t.com...
I am trying to get the save/open dialog figured out. I am able open the
save
dialog but when I put in a file name (whatever.txt) and save the file

does save with the name but it is blank. Below is what I have code so far.

Dim phonestreamwriter As StreamWriter
Dim responsedialogresults As DialogResult
SaveFileDialog1.InitialDirectory = Application.StartupPath
responsedialogresults = SaveFileDialog1.ShowDialog
If responsedialogresults <> DialogResult.Cancel Then
phonestreamwriter = New StreamWriter(SaveFileDialog1.FileName)
End If


Jul 21 '05 #4

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

Similar topics

4
by: Andras Gilicz | last post by:
Hi VB fans I'm working on a relatively large project in VB6 with about a dozen forms, including graphs, labels, text boxes, etc. The software itself is actually a flow simulator with more or...
4
by: John | last post by:
Hi, I generate a report in a comma delimited file and give it a name like MyReport.csv . I then set a Hyperlink control to point tp the file HyperLink1.text = "Download"...
0
by: Dune | last post by:
Hi there, I have an aspx page that allows users to enter several parameters using drop downs and text boxes. The users then press a button that produces an extract based on the parameters they...
6
by: Mike | last post by:
can i open the save file dialog box from a asp.net web page? thx
4
by: sunilj20 | last post by:
Hello, I have a requirement wherein, a user clicks on a file name in an ASP.NET web application, and the file should automatically be downloaded (Without showing the "Open", "Save As") in the...
5
by: Patrick | last post by:
Following on from the excellent example at http://www.c-sharpcorner.com/Code/2003/Sept/ExportASPNetDataGridToExcel.asp on how to save a data-grid to excel file, how can I extend the example such...
3
by: Newbie | last post by:
I am trying to get the save/open dialog figured out. I am able open the save dialog but when I put in a file name (whatever.txt) and save the file does save with the name but it is blank. Below...
6
by: Michael Groeger | last post by:
Hi, I have an aspx page which generates an excel document and transfers it to the browser as attachment. Normally, once the document is transferred the open save dialog prompts to open or save...
1
by: Rameel | last post by:
Friends, I'm probably being more critical with VB.Net Windows application. I have Developed VisualStudio 20005 VB.Net Windows application how willl i be able to save a specific record into my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
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,...
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...

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.