Writing file to directory executable is running in

Posted on 2011-05-10
Last Modified: 2012-08-14
I would like to save a file i am creating using vb studio 2010 to the same path the application is running from, code below
Using writer As StreamWriter = New StreamWriter(Log & ".txt", True)

Open in new window

Question by:sykotex
    LVL 69

    Expert Comment

    by:Éric Moreau
    if you don't specify the folder, it should automatically be there.

    otherwise, try application.startuppath
    LVL 53

    Expert Comment

    LVL 85

    Accepted Solution

    If you're running Vista or Win 7 then it will cause errors trying to write to that folder.

    Instead, try writing to CurrentUserApplicationData:

        Dim LogFile As String = System.IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData, "Log.txt")

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Article by: jpaulino
    XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    729 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

    19 Experts available now in Live!

    Get 1:1 Help Now