Example #1
0
        /// <summary>
        ///  文件保存
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="stream"></param>
        /// <returns></returns>
        public static bool SaveFile(string filePath, Stream stream)
        {
            bool result = true;

            try
            {
                //if (File.Exists(filePath))
                //{
                //    return false;
                //}
                using (FileStream fileStream = new FileStream(filePath, FileMode.Create))
                {
                    byte[] bytes = StreamKit.ToBytes(stream);
                    fileStream.Write(bytes, 0, bytes.Length);
                }
            }
            catch (Exception)
            {
                result = false;
            }
            return(result);
        }