Results 1 to 3 of 3

Thread: Saving files location

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2011
    Posts
    7

    Question Saving files location

    I have used the following code too save a notepad file;
    Code:
    Dim responsedialogueResult As DialogResult
            Dim savedataFile As New SaveFileDialog
            With savedataFile
                Dim SP, Quiz, f1 As String
                SP = Application.StartupPath
                Quiz = "Quizes"
                f1 = Path.Combine(SP, Quiz)
                .InitialDirectory = f1
                .FileName = saveas
                .Title = "Select file or directory file"
                responsedialogueResult = .ShowDialog
                .DefaultExt = "txt"
                .Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"
                .OverwritePrompt = True
                .AddExtension = True
            End With
            If responsedialogueResult <> Windows.Forms.DialogResult.Cancel Then
                filesave = My.Computer.FileSystem.OpenTextFileWriter(saveas, False)
    The code saves files but only in the 'Application.StartupPath' folder, the save dialogue starts in the correct place a quizzes folder inside the debug folder but files can't be saved here or in folders inside it, even though you can browse them in the dialogue. I want it saving where navigated to in the dialogue. Any help?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Saving files location

    Look at the value you're passing to OpenTextFileWriter for the file path. Is that the path that the user chose?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Saving files location

    ugh...
    well first, you're calling .ShowDialog in the middle of setting your properties... that should be the LAST thing you do...
    secondly, you never get the filename or path that the user selected...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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