Ejemplo n.º 1
0
        private async Task ZipFolderContents(StorageFolder sourceFolder, ZipArchive archive, string baseDirPath)
        {
            var files = await sourceFolder.GetFilesAsync();

            var pattern = FileNamingParameters.GetRegex();

            foreach (var file in files)
            {
                if (pattern.Match(file.Name).Success)
                {
                    var readmeEntry = archive.CreateEntry(file.Name);

                    var buffer = await ReadStorageFileToByteBuffer(file);

                    var entryStream = readmeEntry.Open();
                    await entryStream.WriteAsync(buffer, 0, buffer.Length);

                    await entryStream.FlushAsync();

                    entryStream.Dispose();
                }
            }
        }
Ejemplo n.º 2
0
        public void TestRegexEverythingOn()
        {
            var naming = new FileNamingParameters()
            {
                IncludeLevel     = true,
                IncludeLogger    = true,
                IncludeSequence  = true,
                IncludeSession   = true,
                IncludeTimestamp = FileTimestampMode.DateTime
            };

            // get...
            var regex = naming.GetRegex();

            // create...
            var info = GetLogEventInfo();

            // check...
            var context  = new LogWriteContext();
            var filename = naming.GetFilename(context, info);

            // check...
            Assert.True(regex.Match(filename).Success);
        }