Results 1 to 5 of 5

Thread: [RESOLVED] Streamwriter file location

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2004
    Posts
    541

    Resolved [RESOLVED] Streamwriter file location

    Hello all,

    When there's no file path in the streamwriter constructor does anyone know the location the file gets output to?

    ie
    Code:
    Dim sw as StreamWriter = new Streamwriter("test.txt")
    sw.close
    Thanks,

    Strick

  2. #2
    New Member
    Join Date
    Oct 2009
    Posts
    8

    Re: Streamwriter file location

    The file gets output to the working directory, which is usually the folder containing the executable. The user can change the working directory using a shortcut, though, and you can also change the working directory using ChDir and SetWorkingDirectory.

    To always write to the application's folder, use:
    Code:
    Application.StartupPath & "\test.txt"

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

    Re: Streamwriter file location

    The "current" directory. Could be where the app is located. Could be the root.... could be anywhere. Generally speaking, it's a good idea to include the path where you want the file to be.

    -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??? *

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2004
    Posts
    541

    Re: Streamwriter file location

    Quote Originally Posted by techgnome View Post
    The "current" directory. Could be where the app is located. Could be the root.... could be anywhere. Generally speaking, it's a good idea to include the path where you want the file to be.

    -tg
    Hi, I totally agree with you, and I always do. But i'm studying towards the MCPD certification and all the samples in the book where a file is being created does not have the full path, only the file name.

    Thanks,

    Strick

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2004
    Posts
    541

    Re: Streamwriter file location

    Quote Originally Posted by Arrival View Post
    The file gets output to the working directory, which is usually the folder containing the executable. The user can change the working directory using a shortcut, though, and you can also change the working directory using ChDir and SetWorkingDirectory.

    To always write to the application's folder, use:
    Code:
    Application.StartupPath & "\test.txt"
    Hi, Thanks

    I'll check there for it.

    Strick

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