VB.Net SaveFileDialog

Posted on 2014-07-15
Last Modified: 2014-07-20
In VB.Net 2008

Using SavefileDialog as you select the Directory and folder can you show the path in the file name: text
if so how

Question by:Kevinfeening
    LVL 35

    Expert Comment

    by:Miguel Oz
    Could you clarify your question?
    The property Filename contains both the  file path and extension.
    e.g. A filename value could be:
    if you need only the file name not the path use Path.GetFilename method:
    This method returns myfilename.txt

    For other path methods and code samples on how to extract only parts of your file path, check:
    LVL 83

    Expert Comment

    You cannot (easily) change the behaviour of built in dialog boxes and as far as I know, there isn't an option to enable this behaviour.

    Author Comment

    The property filename is empty
    I want when the user clicks on the directory etc it to populate the savefileDialog.filename
    LVL 35

    Accepted Solution

    If you require to select a directory, then you need to use property SelectedPath  from FolderBrowserDialog

    Code snippet from MSDN:
    Dim result As DialogResult = folderBrowserDialog1.ShowDialog() 
    If ( result = DialogResult.OK ) Then
               folderName = folderBrowserDialog1.SelectedPath 
               ' this sample assign selected directory to open a file dialog but you can replace with save dialog as well 
                If (not fileOpened) Then 
                    ' No file is opened, bring up openFileDialog in selected path.
                    openFileDialog1.InitialDirectory = folderName 
                    openFileDialog1.FileName = nothing
                End If 
    End If 

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now