Link to home
Start Free TrialLog in
Avatar of bryanche
bryanche

asked on

How to save a file without using SaveFileDialog control?

Dear Experts:
I'm developing windows based application using VB.net. I would like to save an image to a specific folder without using SaveFileDialog control. I have a button to browse for image using OpenFileDialog. Once the image is selectd from some folder the image gets set to an image holder (PictureBox) the Private strImagePath will be holding the file name and path. Now I have another button that should save the image inside the folder that I want without using savefiledialog control. any help is really appreciated.
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here's an example:

        Dim saveDiag As New SaveFileDialog()
        saveDiag.ShowDialog()

        Dim sText As String = "Text to save to file"

        My.Computer.FileSystem.WriteAllText(saveDiag.FileName, sText, False)

Oops, sorry.  Here you go:

        Dim strImagePath As String = "C:\starbucks logo.jpg"
        Dim savePath As String = "c:\temp\" & System.IO.Path.GetFileName(strImagePath)
        With My.Computer.FileSystem
            .WriteAllBytes(savePath, .ReadAllBytes(strImagePath), False)

        End With

        MsgBox("Saved")