Create a folder and write a file to it

Posted on 2007-10-14
Last Modified: 2013-11-26
I would  like to write  the file that I am testing to the c:\data\In-string.txt

objStreamWriter = System.IO.File.CreateText("In-string.txt")
Question by:WDJ98338

    Author Comment

    Thanks for your help with this.
    LVL 11

    Accepted Solution

                  if (!Directory.Exists)

                    File.AppendAllText("c:\\data\\In-string.txt", "Content of the file");
    LVL 11

    Assisted Solution

    if u want to use StreamWriter

                     if (!Directory.Exists)

                     StreamWriter objStreamWriter = File.CreateText("c:\\data\\In-string.txt");

                     objStreamWriter.Write("Content of file");


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
    Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    758 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

    11 Experts available now in Live!

    Get 1:1 Help Now