This project is read-only.

Exception when output to single file


I get an exception when I use the -filename option. This is when you want all script to go to the same file.
After looking though the code it seems that GetStreamWriter has an assumption. The code gets the directory name, and checks to see that the directory exists. If it doesn't then it tries to create it. If you feed it something like C:\DBCreateScript.sql, then there isn't a directory and you get an exception. This is my solution :
   private StreamWriter GetStreamWriter(string Path, bool Append)
        if (_OutputFileName != null)
            Path = OutputFileName.Trim();
            Append = true;
        if (OutputFileName == "-")
            return new StreamWriter(System.Console.OpenStandardOutput());
        string DirName = System.IO.Path.GetDirectoryName(Path);
        if (DirName.Length > 0 && !Directory.Exists(DirName))
        return new StreamWriter(Path, Append);
One more point. I was confused when I ran with '-TableOneFile' From reading the help generated with ?,
-TableOneFile - script table definition into one file instad of multiple
I think it would be helpfull if it read
-TableOneFile - write scripts associated with a table into one file (triggers/indexes etc)