472,342 Members | 1,634 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

save file dialog?

how can i create a code to make my program create an rtf file? heres what i
have so far, any help would be appreciated:
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuSave.Click
Me.SaveFileDialog1.ShowDialog()
Me.SaveFileDialog1.CheckFileExists = True
Me.SaveFileDialog1.CheckPathExists = True
Me.SaveFileDialog1.AddExtension = True
Me.SaveFileDialog1.DereferenceLinks = True
Me.SaveFileDialog1.DefaultExt = ".rtf"
End Sub
Nov 21 '05 #1
21 7076
SaveFileDialog1.Filter = "RTF Files (*.rtf)|*.rtf"
Nov 21 '05 #2

That still didnt work, should it look like:
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuSave.Click
Me.SaveFileDialog1.ShowDialog()
Me.SaveFileDialog1.CheckFileExists = True
Me.SaveFileDialog1.CheckPathExists = True
Me.SaveFileDialog1.AddExtension = True
Me.SaveFileDialog1.DereferenceLinks = True
Me.SaveFileDialog1.Filter = "RTF Files (*.rtf)|*.rtf"

End Sub
Nov 21 '05 #3
Dim strFilename As String
With SaveFileDialog1
.DefaultExt = "rtf"
.Filter = "RTF (*.rtf)|*.rtf|All Files (*.*)|*.*"
.FilterIndex = 0
.InitialDirectory =
Environment.GetFolderPath(Environment.SpecialFolde r.Desktop)
If .ShowDialog = DialogResult.OK Then
strFilename = .FileName
Else
Exit Sub
End If
End With
MessageBox.Show(strFilename)
Nov 21 '05 #4
i put that in, it says its saved yet the file isnt there
Nov 21 '05 #5
You originally asked about the file save dialog, which you got.

Here;s the full code to create the file too:

Dim strFilename As String
With SaveFileDialog1
.DefaultExt = "rtf"
.Filter = "RTF (*.rtf)|*.rtf|All Files (*.*)|*.*"
.FilterIndex = 0
.InitialDirectory =
Environment.GetFolderPath(Environment.SpecialFolde r.Desktop)
If .ShowDialog = DialogResult.OK Then
strFilename = .FileName
Else
Exit Sub
End If
End With
Dim sw As New IO.StreamWriter(strFilename)
sw.Close()

That will do the trick. Just copy/paste it in your menu click event.

By the way: It creates an EMPTY file & closes it.
Nov 21 '05 #6
if i go to the open dialog will the file open and have everything that was
shwon on the screen?
Nov 21 '05 #7
RTF files are usually handled by MS Word or Wordpad if MS Office isn't
installed. You will notice the file icon is either Wordpad or MS Word

So, use the same idea as the save file dialog & it shall open
Nov 21 '05 #8
whats the open file code if i wanted to open this file? and will it show it
exactly how i left it if there are pictures, labels, and text boxes or should
i use a different file format?
Nov 21 '05 #9
The code that goes between the StreamWriter & the close should be from a RTF
textbox & not a normal textbox.

Then use this code (incomplete) to open a Stream Reader object to put the
file into your RTF textbox:

Dim strFilename As String
With OpenFileDialog1
.DefaultExt = "rtf"
.Filter = "RTF (*.rtf)|*.rtf|All Files (*.*)|*.*"
.FilterIndex = 0
.InitialDirectory =
Environment.GetFolderPath(Environment.SpecialFolde r.Desktop)
If .ShowDialog = DialogResult.OK Then
strFilename = .FileName
Else
Exit Sub
End If
End With

As you see, its the same code, but using an OpenFileDialog instead.
Nov 21 '05 #10
Sorry. Forgot the link:

http://www.vb-helper.com/index_graphics.html

Look under graphics for screen printing/capturing

"iwdu15" wrote:
whats the open file code if i wanted to open this file? and will it show it
exactly how i left it if there are pictures, labels, and text boxes or should
i use a different file format?

Nov 21 '05 #11
i copied and pasted a code form the site but it gave me errors all over the
place, and the open thing didnt work, when i opend the file nuthing happened
Nov 21 '05 #12
it also doesnt save anytghing besides an empty file, am i asking too much out
of VB or can i save a my project as a file type with pictures, labels,
buttons etc and oepn it up and edit it later?
Nov 21 '05 #14
i 4got to tell u i dont kno if it matters im using Visual studio.Net 2003
Nov 21 '05 #15
"iwdu15" <iw****@discussions.microsoft.com> schrieb:
how can i create a code to make my program create an rtf file? heres what
i
have so far, any help would be appreciated:
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuSave.Click
Me.SaveFileDialog1.ShowDialog()


'SaveFileDialog' only shows the file selection dialog, but it doesn't
actually create files or save data to files. You will have to do that
yourself:

\\\
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
Me.RichTextBox1.SaveFile(OpenFileDialog1.FileName)
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #16
well then how do u save data to a file so i can open it exactly ghow it was
and start editing it again? im using visual studio.net 2003 btw
Nov 21 '05 #17
I said above that it saves an EMPTY file

I have done a 20-hour day & I am not being funny, but I am not just here to
help you out.

I thought you only wanted the filter line of code. I do not have the time to
write you a full application & add comments to it. I am dead on my feet.
Please don't take it the wrong way if I sound a little off.

Please type:

http://www.google.com & in the search box type:

"RTF", "VB.NET" (including quotes) & press Enter

"Crouchie1998" wrote:
Have a look at this article I found for you:

http://www.vbdotnetheaven.com/Code/Sept2003/2163.asp

Code sample:

http://www.vbdotnetheaven.com/Code/S...ViewerCode.zip

Nov 21 '05 #18
"iwdu15" <iw****@discussions.microsoft.com> schrieb:
well then how do u save data to a file so i can open it exactly ghow it
was
and start editing it again? im using visual studio.net 2003 btw


Place a richtextbox control on your form and use this code to load a file:

\\\
Me.RichTextBox1.LoadFile("C:\foo.rtf")
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #19
ok forgive me for being stupid but this is just my first year programming
anything this complicated so whjat type of rich text control, and how do i
save a file with the data from my applicaton and what format should i have it
save as?
Nov 21 '05 #20
can anybody tell me how to save a file and create it with data from inside a
indows form on visual studio 2003? i want it to save whats in labels, text
boxes and images if it makes a difference...thanks
Nov 21 '05 #21
Isdu15

MSDN is (mostly) a great source .

Here is a complete sample about all your questions you had in this message
thread.

http://msdn.microsoft.com/library/de...FileTopic2.asp

I hope this helps?

Cor
Nov 21 '05 #22

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

Similar topics

3
by: cathywigzell | last post by:
I have a web page which allows a user to download a file directly to their computer, using IE. I present a file name in a table and the user can...
2
by: Alvo von Cossel I | last post by:
hi, i have a textbox in a form. when you press a Save button, a savefiledialog appears. creating ther file works but everytime you click save,...
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...
4
by: Richard | last post by:
Hi I'm new to ASP/Web programming so any help would be appreciated... Situation: On my web page I would like to present a link {or button}...
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...
4
by: Dorte | last post by:
Hi, I am using the code below to stream a CSV file with the response object. Dim FileName As String = "Test.csv" With...
1
by: M Pearson | last post by:
Hello there all, am very new to asp.net programming and am struggling with this problem. What I trying to achieve. On a button click I want the...
4
by: Jonny | last post by:
Hello Group How do I open a Save File Dialog from an ASPX page behind a browse button? Any help would be fantastic!! I am using ASP.NET 1.1...
3
by: =?Utf-8?B?YXNkZg==?= | last post by:
Hello. I am making a web application with c# and am using this code: Response.ContentType = "application/x-excel";...
2
by: vbaDev | last post by:
Hi. I am using Access 2000 and in my code I'm exporting a table into an Excel file (creating it), then the code needs to export another query into...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...

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.