I would like to know if there is any other way to create a doc (or txt) file, then this way that I have in my code:

if (!System.IO.Directory.Exists(System.IO.Path.GetTempPath() + @"TestDirectory"))
                    System.IO.Directory.CreateDirectory(System.IO.Path.GetTempPath() + @"TestDirectory");
                
                string LogDatoteke = System.IO.Path.GetTempPath() + @"TestDirectory\TestFile.doc";
                StreamWriter zapis;
                zapis = File.CreateText(LogDatoteke);
                zapis.WriteLine("Some text 1");
                zapis.WriteLine("");
                zapis.WriteLine("Some text 2");
                zapis.WriteLine("Some text 3");
                zapis.WriteLine("What ever");                
                zapis.Flush();
                zapis.Close();

Functionally, a simple text file is far different than a Word document. But as for creating a simple file, here is another method.

string[] temp = new string[] { "Apple", "Banana", "Cherry" };
string fileName = @"C:\Temp\junk.txt";

File.WriteAllLines(fileName, temp);

Which would create a text file that looks like the following.

Apple
Banana
Cherry
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.