コード例 #1
0
        /// <summary>
        /// Creates a new file, writes the specified byte array to the file, and then closes the file. If the target file already exists, it is overwritten.
        /// </summary>
        /// <param name="path">Path to file.</param>
        /// <param name="bytes">Bytes to write.</param>
        public override void WriteAllBytes(string path, byte[] bytes)
        {
            using (var stream = new System.IO.MemoryStream(bytes))
            {
                Get(path).Upload(stream);
            }

            SynchronizationHelper.LogUpdateFileTask(path);
        }
コード例 #2
0
        /// <summary>
        /// Creates a new file, write the contents to the file, and then closes the file. If the target file already exists, it is overwritten.
        /// </summary>
        /// <param name="path">Path to file</param>
        /// <param name="contents">Content to write</param>
        /// <param name="encoding">The character encoding to use</param>
        public override void WriteAllText(string path, string contents, Encoding encoding)
        {
            using (var stream = new System.IO.MemoryStream(encoding.GetBytes(contents)))
            {
                Get(path).Upload(stream);
            }

            SynchronizationHelper.LogUpdateFileTask(path);
        }
コード例 #3
0
        /// <summary>
        /// Opens a file, appends the specified string to the file, and then closes the file. If the file does not exist, this method creates a file, writes the specified string to the file, then closes the file.
        /// </summary>
        /// <param name="path">Path</param>
        /// <param name="contents">Content to write.</param>
        /// <param name="encoding">The character encoding to use</param>
        public override void AppendAllText(string path, string contents, Encoding encoding)
        {
            var blob = Get(path);

            if (blob.Exists())
            {
                blob.Append(encoding.GetBytes(contents));

                SynchronizationHelper.LogUpdateFileTask(path);
            }
            else
            {
                WriteAllText(path, contents, encoding);
            }
        }
コード例 #4
0
        /// <summary>
        /// Releases all resources.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            // handle closed streams
            if (!_stream.CanSeek)
            {
                // stream has been already disposed
                return;
            }

            Flush();

            if (_fileAccess == FileAccess.Write || _fileAccess == FileAccess.ReadWrite)
            {
                Seek(0, SeekOrigin.Begin);

                BlobHelper.Get(Path).Upload(_stream);

                SynchronizationHelper.LogUpdateFileTask(Path);
            }
        }
コード例 #5
0
        /// <summary>
        /// Copies an existing file to a new file. Overwriting a file of the same name is not allowed.
        /// </summary>
        /// <param name="sourceFileName">Path to source file.</param>
        /// <param name="destFileName">Path to destination file.</param>
        public override void Copy(string sourceFileName, string destFileName)
        {
            Copy(sourceFileName, destFileName, false);

            SynchronizationHelper.LogUpdateFileTask(destFileName);
        }