Example #1
0
        private void write(RssWriter writer)
        {
            try
            {
                if (this.channels.Count == 0)
                    throw new InvalidOperationException("Feed must contain at least one channel.");

                writer.Version = this.rssVersion;
                writer.Modules = this.modules;

                foreach (RssChannel.RssChannel channel in this.channels)
                {
                    if (channel.Items.Count == 0)
                        throw new InvalidOperationException("Channel must contain at least one item.");

                    writer.Write(channel);
                }
            }
            finally
            {
                if (writer != null)
                    writer.Close();
            }
        }
Example #2
0
        /// <summary>
        ///     Writes the RSS feed to the specified file.
        /// </summary>
        /// <remarks>
        ///     The encoding is ISO-8859-1.
        /// </remarks>
        /// <exception cref="ArgumentException">The filename is empty, contains only white space, or contains one or more invalid characters.</exception>
        /// <exception cref="UnauthorizedAccessException">Access is denied.</exception>
        /// <exception cref="ArgumentNullException">The filename is a (null c#, Nothing vb) reference.</exception>
        /// <exception cref="DirectoryNotFoundException">The directory to write to is not found.</exception>
        /// <exception cref="IOException">The filename includes an incorrect or invalid syntax for file name, directory name, or volume label syntax.</exception>
        /// <exception cref="System.Security.SecurityException">The caller does not have the required permission.</exception>
        /// <param name="fileName"> specified file (including path) If the file exists, it will be truncated with the new content. </param>
        /// <exception cref="InvalidOperationException">Feed must contain at least one channel.</exception>
        /// <exception cref="InvalidOperationException">Channel must contain at least one item.</exception>
        public void Write(string fileName)
        {
            RssWriter writer = new RssWriter(fileName);

            this.write(writer);
        }
Example #3
0
 /// <summary>
 ///     Writes the RSS feed to the specified file.
 /// </summary>
 /// <remarks>
 ///     The encoding is ISO-8859-1.
 /// </remarks>
 /// <exception cref="ArgumentException">The filename is empty, contains only white space, or contains one or more invalid characters.</exception>
 /// <exception cref="UnauthorizedAccessException">Access is denied.</exception>
 /// <exception cref="ArgumentNullException">The filename is a (null c#, Nothing vb) reference.</exception>
 /// <exception cref="DirectoryNotFoundException">The directory to write to is not found.</exception>
 /// <exception cref="IOException">The filename includes an incorrect or invalid syntax for file name, directory name, or volume label syntax.</exception>
 /// <exception cref="System.Security.SecurityException">The caller does not have the required permission.</exception>
 /// <param name="fileName"> specified file (including path) If the file exists, it will be truncated with the new content. </param>
 /// <exception cref="InvalidOperationException">Feed must contain at least one channel.</exception>
 /// <exception cref="InvalidOperationException">Channel must contain at least one item.</exception>
 public void Write(string fileName)
 {
     RssWriter writer = new RssWriter(fileName);
     this.write(writer);
 }