Saving a file: Default Extension, Name & Folder

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2009
Posts: 5
Reputation: Zack Richards is an unknown quantity at this point 
Solved Threads: 0
Zack Richards Zack Richards is offline Offline
Newbie Poster

Saving a file: Default Extension, Name & Folder

 
0
  #1
Aug 12th, 2009
Hello, i am currently developing a new OpenSource project.
I will release it to the public this week. :-)

Let's get to my question(s) then:
  • I have a Rich Text Box, and i want to save that text into a default extension.
  • I want the default name to be found in the textbox, E.g: Hello my name is Zack (The file would appear as default name Zack on the Save File Dialog, but if the name was Richards, it would appear Richards instead).
  • Also, the Save File Dialog should open a default folder. (.../Saved)


I lack knowledge in saving files on VB.NET, any help would be greatly appreciated and a great boost on my project.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 269
Reputation: GeekByChoiCe is on a distinguished road 
Solved Threads: 54
GeekByChoiCe GeekByChoiCe is offline Offline
Posting Whiz in Training

Re: Saving a file: Default Extension, Name & Folder

 
0
  #2
Aug 12th, 2009
Add a savefiledialog (here sfd) to your form
the following code you add into your save click event
  1. With sfd
  2. .FileName = stri.Replace("Hello my name is ", "") & ".rtf"
  3. .InitialDirectory = My.Application.Info.DirectoryPath & "/Saved/"
  4. .ShowDialog()
  5. End With

and the next code you just add to your code
  1. Private Sub sfd_FileOk(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles sfd.FileOk
  2. RichTextBox1.SaveFile(sfd.FileName, RichTextBoxStreamType.RichText)
  3. End Sub
Last edited by GeekByChoiCe; Aug 12th, 2009 at 2:26 am. Reason: bb codes :@
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 20
Reputation: freepost is an unknown quantity at this point 
Solved Threads: 0
freepost freepost is offline Offline
Newbie Poster

Re: Saving a file: Default Extension, Name & Folder

 
0
  #3
Aug 12th, 2009
very good
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 5
Reputation: Zack Richards is an unknown quantity at this point 
Solved Threads: 0
Zack Richards Zack Richards is offline Offline
Newbie Poster

Re: Saving a file: Default Extension, Name & Folder

 
0
  #4
Aug 12th, 2009
Thank you, you really helped me.
Will be sure to stay here at DaniWeb.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 5
Reputation: Zack Richards is an unknown quantity at this point 
Solved Threads: 0
Zack Richards Zack Richards is offline Offline
Newbie Poster

Re: Saving a file: Default Extension, Name & Folder

 
0
  #5
Aug 12th, 2009
What do you mean with "stri", it says that it is not declared.
I am using Visual Basic 2008
Last edited by Zack Richards; Aug 12th, 2009 at 9:00 am.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 269
Reputation: GeekByChoiCe is on a distinguished road 
Solved Threads: 54
GeekByChoiCe GeekByChoiCe is offline Offline
Posting Whiz in Training

Re: Saving a file: Default Extension, Name & Folder

 
0
  #6
Aug 12th, 2009
stri can be replaced by Textbox1.Text
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 5
Reputation: Zack Richards is an unknown quantity at this point 
Solved Threads: 0
Zack Richards Zack Richards is offline Offline
Newbie Poster

Re: Saving a file: Default Extension, Name & Folder

 
0
  #7
Aug 12th, 2009
Thanks, this is almost solved.
The problem is:
  • if there is a large text in the textbox, i would like to delete it from the filename, only getting the "my name is Zack" part, therefore making it possible to write a whole text and it finds "my name is Zack" somewhere, and gets Zack as filename (Zack has example, could be Richards or anything else.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 269
Reputation: GeekByChoiCe is on a distinguished road 
Solved Threads: 54
GeekByChoiCe GeekByChoiCe is offline Offline
Posting Whiz in Training

Re: Saving a file: Default Extension, Name & Folder

 
0
  #8
Aug 13th, 2009
Thats pretty hard if the text is always different. A simple solution would be that you force the user to write their name into a sepearate textbox so you can use that as the file name.
If you want to stick to the solution you already have then it will be pretty hard because you never know where the name is and users normally never stick to the syntax, so you cant trust them that they will always write "hello my name is blabla"
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 5
Reputation: Zack Richards is an unknown quantity at this point 
Solved Threads: 0
Zack Richards Zack Richards is offline Offline
Newbie Poster

Re: Saving a file: Default Extension, Name & Folder

 
0
  #9
Aug 13th, 2009
This would be used for a Java Compiler.
Which always has the "public class Scriptname" part, which "Scriptname" has to be the name of the file.
Thank you for your help, but is it anyway to do this?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC