473,756 Members | 6,028 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.EventArg s) Handles mnuSave.Click
Me.SaveFileDial og1.ShowDialog( )
Me.SaveFileDial og1.CheckFileEx ists = True
Me.SaveFileDial og1.CheckPathEx ists = True
Me.SaveFileDial og1.AddExtensio n = True
Me.SaveFileDial og1.Dereference Links = True
Me.SaveFileDial og1.DefaultExt = ".rtf"
End Sub
Nov 21 '05 #1
21 7187
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.EventArg s) Handles mnuSave.Click
Me.SaveFileDial og1.ShowDialog( )
Me.SaveFileDial og1.CheckFileEx ists = True
Me.SaveFileDial og1.CheckPathEx ists = True
Me.SaveFileDial og1.AddExtensio n = True
Me.SaveFileDial og1.Dereference Links = True
Me.SaveFileDial og1.Filter = "RTF Files (*.rtf)|*.rtf"

End Sub
Nov 21 '05 #3
Dim strFilename As String
With SaveFileDialog1
.DefaultExt = "rtf"
.Filter = "RTF (*.rtf)|*.rtf|A ll Files (*.*)|*.*"
.FilterIndex = 0
.InitialDirecto ry =
Environment.Get FolderPath(Envi ronment.Special Folder.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|A ll Files (*.*)|*.*"
.FilterIndex = 0
.InitialDirecto ry =
Environment.Get FolderPath(Envi ronment.Special Folder.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|A ll Files (*.*)|*.*"
.FilterIndex = 0
.InitialDirecto ry =
Environment.Get FolderPath(Envi ronment.Special Folder.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

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

Similar topics

3
4182
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 then right click on the file name to get a popup menu with the option 'Save Target As...'. Selecting that option results in the Save As dialog. However, if the filename has a reconginsed extension, e.g. .doc, then the Save As dialog adds another extension, so the file name in the Save As dialog...
2
2369
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, the dialog appears. how do i make the dialog appear once and then only save the file? thanx -- Alvo von Cossel I of Germany
4
5108
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" Hyperlink1.NavigateUrl = "MyReport.csv" When the user clicks the HyperLink I would always like to
4
5560
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} that would allow the user to download a large file. When the user clicks to start the download I would like to display the "Save As" dialog, allow the user to name a place to save the file, and then show the download progress bar while the file downloads Question: How do I make a windows "Save...
0
2979
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 entered. When this button is pressed and extract is prduced and IE's standard Open/Save dialog should popup so they can navigate to the directory to save the extract in, or if they want, they can choose to open and view the extract without saving it. ...
4
3688
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 Web.HttpContext.Current.Response Web.HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" & FileName) .Charset = ""
1
1451
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 standard web save as dialog to display. The user specifies where to save. I then generate the file which is a series of reports zipped up, which then gets saved to the users pc. The following is some sample code:
4
6262
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 using VB.NET as the coding language TIA
3
6440
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"; Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("あいうえお") + ".csv"); Encoding encoding = Encoding.GetEncoding("Shift-JIS"); Response.BinaryWrite(encoding.GetBytes(csvStr)); Response.End(); It works fine..the data gets saved nicely to an excel file. The user pushes the...
2
10995
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 the same file (a new worksheet). So I needed both a "Save As" dialog and the ability to grab the filepath so that the second export appends to it. Anyway, I found Microsofts method and it works, except that I can't figure out how to populate the File Name box in the Dialog with a default name (say,...
0
9212
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9790
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9645
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 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...
0
8645
agi2029
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 projectplanning, coding, testing, and deploymentwithout 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...
0
6473
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();...
0
5069
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...
0
5247
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3276
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2612
bsmnconsultancy
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...

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.