• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 291
  • Last Modified:

Create a folder and write a file to it

I would  like to write  the file that I am testing to the c:\data\In-string.txt

Using:
objStreamWriter = System.IO.File.CreateText("In-string.txt")
0
WDJ98338
Asked:
WDJ98338
  • 2
2 Solutions
 
WDJ98338Author Commented:
Thanks for your help with this.
0
 
udhayakumardCommented:
              if (!Directory.Exists)
                    Directory.CreateDirectory("C:\\data");

                File.AppendAllText("c:\\data\\In-string.txt", "Content of the file");
0
 
udhayakumardCommented:
if u want to use StreamWriter

                 if (!Directory.Exists)
                    Directory.CreateDirectory("C:\\data");

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

                 objStreamWriter.Write("Content of file");

                 objStreamWriter.Close();
0

Featured Post

Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now