Results 1 to 9 of 9
  1. #1
    ppl2pass's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Posts
    804
    Reputation
    5
    Thanks
    111
    My Mood
    Amused

    Question [Help]Save Text to Desktop[Solved]

    How do you make an option in vb.net to save text to desktop?

  2. #2
    Blubb1337's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Germany
    Posts
    5,915
    Reputation
    161
    Thanks
    3,108
    did you google yet?...

    google for streamwriter.



  3. #3
    Bombsaway707's Avatar
    Join Date
    Jun 2009
    Gender
    male
    Location
    Gym
    Posts
    8,799
    Reputation
    791
    Thanks
    4,004
    My Mood
    Amused
    Let me google that for you
    Click It Click It Click It, its majix

  4. The Following User Says Thank You to Bombsaway707 For This Useful Post:

    NextGen1 (03-15-2010)

  5. #4
    zmansquared's Avatar
    Join Date
    Oct 2008
    Gender
    male
    Location
    Kickin it at Microsoft
    Posts
    2,086
    Reputation
    36
    Thanks
    221
    My Mood
    Cheerful
    Here you go. Thank me please

    Change the user name to yours

    [php]Imports System.IO
    Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim TextFile As New StreamWriter("c:\Users\Zack\Desktop\test.txt")
    TextFile.WriteLine("Text here")
    ' make more of these TextFile.WriteLine("Text here")to get more lines.
    TextFile.Close()



    End Sub
    End Class[/php]
    Need Help With Coding or Something??? MSN me
    zmansquared@hotmail.com


    I am the one and only Microsoft Fag!!!

    Quote:
    Originally Posted by Arhk
    All games should be hacked, if we don't do it someone else will. Hackers force the progress, of better programming methods.
    ~


    Take this Pic everyone!



    next-

  6. #5
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    Professionally and commercially you would want to do this without hard-coding the direct path , because if a 3rd party uses it, they will not be able to save the txt file to the desktop path.

    Use

    [php]
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim DesktopPath As String = Environment.GetFolderPath(Environment.SpecialFolde r.DesktopDirectory)

    Dim TextFile As New StreamWriter(DesktopPath & test.txt")
    TextFile.WriteLine("Text here") ' or textbox.text
    ' make more of these TextFile.WriteLine("Text here")to get more lines.
    TextFile.Close()


    End Sub
    [/php]

    A good note to all developers is to remember that vb.net allows you to access user folders as special folders without hardcoding the user name and path

    [php]
    Environment.SpecialFolder.
    [/php]

    This will give you access to

    Cookies
    Desktop
    My Pictures
    My Documents
    History
    etc
    etc

    Without the need for the username

    added to code snippets vault post 1


    this will allow saving to anyones desktop


    Last edited by NextGen1; 03-15-2010 at 06:37 PM.


     


     


     



    The Most complete application MPGH will ever offer - 68%




  7. The Following 2 Users Say Thank You to NextGen1 For This Useful Post:

    ppl2pass (03-15-2010),why06 (03-16-2010)

  8. #6
    zmansquared's Avatar
    Join Date
    Oct 2008
    Gender
    male
    Location
    Kickin it at Microsoft
    Posts
    2,086
    Reputation
    36
    Thanks
    221
    My Mood
    Cheerful
    You copied some of my code nextgen . LOL
    Need Help With Coding or Something??? MSN me
    zmansquared@hotmail.com


    I am the one and only Microsoft Fag!!!

    Quote:
    Originally Posted by Arhk
    All games should be hacked, if we don't do it someone else will. Hackers force the progress, of better programming methods.
    ~


    Take this Pic everyone!



    next-

  9. #7
    NextGen1's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Not sure really.
    Posts
    6,312
    Reputation
    382
    Thanks
    3,019
    My Mood
    Amazed
    Its MSDN Standard, But yes I part of your above example to make sense of the prior :d
    Last edited by NextGen1; 03-15-2010 at 07:28 PM.


     


     


     



    The Most complete application MPGH will ever offer - 68%




  10. #8
    zmansquared's Avatar
    Join Date
    Oct 2008
    Gender
    male
    Location
    Kickin it at Microsoft
    Posts
    2,086
    Reputation
    36
    Thanks
    221
    My Mood
    Cheerful
    Woot Nextgen1 used one of my examples WOOT. HAH thanks
    Need Help With Coding or Something??? MSN me
    zmansquared@hotmail.com


    I am the one and only Microsoft Fag!!!

    Quote:
    Originally Posted by Arhk
    All games should be hacked, if we don't do it someone else will. Hackers force the progress, of better programming methods.
    ~


    Take this Pic everyone!



    next-

  11. #9
    MJLover's Avatar
    Join Date
    Feb 2010
    Gender
    male
    Location
    Neverland
    Posts
    759
    Reputation
    33
    Thanks
    110
    My Mood
    Cheerful

    Talking

    OR

    [php] My.Computer.FileSystem.WriteAllText(My.Computer.Fi leSystem.SpecialDirectories.Desktop & "\filename.txt", "Text here...", False)
    [/php]

Similar Threads

  1. [Help] Saving resources to disk?[Solved]
    By master131 in forum Visual Basic Programming
    Replies: 3
    Last Post: 12-16-2010, 02:22 AM
  2. [Help]Save Contents of TextBox[Solved][Closed]
    By bayley60 in forum Visual Basic Programming
    Replies: 2
    Last Post: 07-17-2010, 03:06 PM
  3. [Help]Save track bar settings[Solved]
    By jajarem64 in forum Visual Basic Programming
    Replies: 16
    Last Post: 06-17-2010, 11:03 PM
  4. [Help]Save Text[Solved]
    By Shark23 in forum Visual Basic Programming
    Replies: 7
    Last Post: 04-15-2010, 11:08 AM
  5. [Help] Save Items in Combobox[Solved]
    By FatCat00 in forum Visual Basic Programming
    Replies: 8
    Last Post: 04-13-2010, 04:01 AM