Exemple #1
0
        /// <summary>
        /// Uploaded content of object
        /// </summary>
        /// <param name="file">Object content</param>
        /// <param name="append">When true download content and append new content at the end of current content, else overwrite current content by new content</param>
        public virtual void UpdateContent(ref Stream file, bool append)
        {
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            if (append)
            {
                string f = Path.GetTempFileName();
                using (FileStream fs = new FileStream(f, FileMode.Create))
                {
                    Download(fs, null);
                    file.CopyTo(fs);
                }
                file = new FileStream(f, FileMode.Open);
            }
            string usrid = User.Get("").Id;

            try
            {
                if (string.IsNullOrEmpty(ParentId))
                {
                    T        obj = Get(Id);
                    string[] lid = (obj as AFiles <T>).ParentId.Split('.');
                    UploadContent(file, usrid, Name, lid[lid.Length - 1], 0, null, null, null);
                }
                else
                {
                    string[] lid = ParentId.Split('.');
                    UploadContent(file, usrid, Name, lid[lid.Length - 1], 0, null, null, null);
                }
            }
            catch
            {
                throw;
            }
        }