示例#1
0
        /// <summary>
        ///     Works out the size of a given file.
        /// </summary>
        /// <param name="file">File to work out size of.</param>
        /// <returns>Size of the given file.</returns>
        public static int FileSize(string file)
        {
            Stream stream = StreamFactory.RequestStream(file, StreamMode.Open);
            int    length = (int)stream.Length;

            stream.Close();
            return(length);
        }
 /// <summary>
 ///		Loads this XML configuration file's data from a file .
 /// </summary>
 /// <param name="url">Url of file to read data from.</param>
 public void Load(object url)
 {
     if (url is BinaryReader)
     {
         _xmlDocument.Load((url as BinaryReader).BaseStream);
     }
     else
     {
         Stream stream = StreamFactory.RequestStream(url, StreamMode.Open);
         if (stream == null)
         {
             return;
         }
         _xmlDocument.Load(stream);
         stream.Close();
     }
 }
 /// <summary>
 ///		Saves this XML configuration file into a file.
 /// </summary>
 /// <param name="url">Url of file to write data into.</param>
 public void Save(object url)
 {
     if (url is BinaryWriter)
     {
         _xmlDocument.Save((url as BinaryWriter).BaseStream);
     }
     else
     {
         Stream stream = StreamFactory.RequestStream(url, StreamMode.Truncate);
         if (stream == null)
         {
             return;
         }
         _xmlDocument.Save(stream);
         stream.Close();
     }
 }