示例#1
0
        private static SimpleFile CreateTextFile(string pre, string path)
        {
            var guid     = Guid.NewGuid().ToString();
            var fileName = $"{GetFileName(pre, guid)}.txt";
            var dir      = Path.Combine(path, fileName);

            File.AppendAllText(dir, guid);
            var sf = new SimpleFile(dir, Mode.Text, new FileInfo(dir).Length, fileName)
            {
                TextContent = guid
            };

            return(sf);
        }
示例#2
0
        private static SimpleFile CreateBinaryFile(string pre, string path)
        {
            var guid     = Guid.NewGuid();
            var bs       = guid.ToByteArray();
            var fileName = $"{GetFileName(pre, guid.ToString())}.bin";
            var dir      = Path.Combine(path, fileName);

            File.WriteAllBytes(dir, bs);
            var sf = new SimpleFile(dir, Mode.Text, new FileInfo(dir).Length, fileName)
            {
                BinaryContent = bs
            };

            return(sf);
        }