Click here to Skip to main content
15,897,371 members
Articles / Database Development / SQL Server

Tier Generator 1.0

Rate me:
Please Sign up or sign in to vote.
4.89/5 (140 votes)
26 Jul 2008CPOL2 min read 256.7K   13.3K   297  
A powerful tool for rapid application development.
using System;
using System.IO;

namespace TierGenerator.CodeGeneration
{
    /// <summary>
    /// Write the code File
    /// </summary>
    class FileWriter
    {


        /// <summary>
        /// method to create File
        /// </summary>
        /// <param name="folderPath">Folder Path</param>
        /// <param name="fileName">file name</param>
        /// <param name="fileText">file text</param>        
        public static void WriteFile(string folderPath, string fileName, string fileText)
        {
            // Check Folder
            CheckFolder(folderPath);

            string filePath = folderPath + Path.DirectorySeparatorChar + fileName;
            using (StreamWriter sw = new StreamWriter(filePath))
            {
                sw.Write(fileText);
                sw.Flush();
                sw.Close();
            }
                        
        }

        /// <summary>
        /// method to check the existance of the folder. if folder not exist then it create it
        /// </summary>
        /// <param name="folderPath">path of the folder</param>
        public static  void CheckFolder(string folderPath)
        {

            if (!Directory.Exists(folderPath))
            {
                Directory.CreateDirectory(folderPath);
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer
Pakistan Pakistan
Passion and positive dedication is essential part of success. I believe on hardworking and sharing knowledge with others. I always try to be a better than I am and think positive for positive result.

My Blogs

My Linked-In Profile

Comments and Discussions