Example #1
0
        public bool Write(byte[] bytes, bool overwriteExisting = true)
        {
            string e; Trace_i("Writing bytes to file...");

            if (
                _fs.TryWriteFile(this.Path, out e, bytes, overwriteExisting)
                )
            {
                return(Trace_o("Successfully written bytes to file."));
            }
            else
            {
                return(Error_o("Failed to write bytes to file." + L.F + e));
            }
        }
Example #2
0
        private async Task <bool> QueryThenCacheToFile(CancellationToken tkn)
        {
            if (!await Query(_client, _subURL, tkn))
            {
                return(false);
            }

            var json = _serialr.Write(_list, false);
            var msg  = $"‹{ClsTyp}› query: {_list.Count.x("record")} ({json.Length.KB()})";

            if (_file.Found && SameAs(_file, json, msg))
            {
                return(true);
            }


            string err;

            if (_fs.TryWriteFile(_file.Path, out err, json, EncodeAs.UTF8))
            {
                return(Debug_n($"New cache file created: “{_file.Name}”.", msg));
            }
            else
            {
                return(Warn_n($"Failed to write cache file for ‹{ClsTyp}›.", err));
            }
        }