Results 1 to 6 of 6

Thread: A Quick Saving Question *Solved*

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2013
    Location
    Earth
    Posts
    230

    A Quick Saving Question *Solved*

    Hello! What I am trying to do is to have 1 button in a form save both a bitmap and a text file in the same folder with just one click. So what I wanted it to do was to open a FolderBrowserDialog for the user to select a folder to save them in. I get the MsgBox saying "done" at the end though, but I see no created files.
    Nothing is saved with this code:
    vb Code:
    1. Private Sub ButtonSave_Click(sender As System.Object, e As System.EventArgs) Handles ButtonSave.Click
    2.         If MessageBox.Show("Would you like to save?", "Save As...", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
    3.             MessageBox.Show("Please choose a folder.", "Save As...", MessageBoxButtons.OK)
    4.             If FolderBrowserDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
    5.                 Dim Map As New Bitmap(PanelFullMapToSave.Width, PanelFullMapToSave.Height)
    6.                 PanelFullMapToSave.DrawToBitmap(Map, New Rectangle(0, 0, PanelFullMapToSave.Width, PanelFullMapToSave.Height))
    7.                 Map.Save(FolderBrowserDialog1.SelectedPath & "bitmap.png", System.Drawing.Imaging.ImageFormat.Png)
    8.                 Dim SW As System.IO.StreamWriter = New System.IO.StreamWriter(FolderBrowserDialog1.SelectedPath & "data.txt")
    9.                 SW.WriteLine(Data)
    10.                 SW.Dispose()
    11.                 MsgBox("done")
    12.             End If
    13.         End If
    14.     End Sub

    HOWEVER I had previously used this code using a SaveFileDialog, and it worked (saved the bitmap in the location.) In this case I had only saved the bitmap.
    vb Code:
    1. Private Sub ButtonSave_Click(sender As System.Object, e As System.EventArgs) Handles ButtonSave.Click
    2.         If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
    3.             Dim Map As New Bitmap(PanelFullMapToSave.Width, PanelFullMapToSave.Height)
    4.             PanelFullMapToSave.DrawToBitmap(Map, New Rectangle(0, 0, PanelFullMapToSave.Width, PanelFullMapToSave.Height))
    5.             Map.Save(SaveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Png)
    6.         End If
    7.     End Sub

    Did I miss something in the first block of code? Thanks.
    Last edited by NinjaNic; Aug 2nd, 2014 at 03:37 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width