Ejemplo n.º 1
0
        public void CreateIfNotExists_Test()
        {
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test01\\");

            FilePathUtil.CreateIfNotExists(path);
            Assert.True(Directory.Exists(path));
            FilePathUtil.CreateIfNotExists(path);

            FilePathUtil.DeleteDirIfExist(path, false);
            Assert.False(Directory.Exists(path));
        }
Ejemplo n.º 2
0
        public void DeleteIfExist()
        {
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "test02\\");

            FilePathUtil.CreateIfNotExists(path);

            var filePath = Path.Combine(path, "1.text");

            File.WriteAllText(filePath, "haha");
            Assert.True(File.Exists(filePath));
            Assert.True(FilePathUtil.DeleteFileIfExists(filePath));
            Assert.False(FilePathUtil.DeleteFileIfExists(filePath));
            Assert.False(File.Exists(filePath));

            Directory.Delete(path, true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initialize
        /// </summary>
        public void Initialize()
        {
            if (_initialized)
            {
                _logger.LogDebug("The train '{0}' in  file pool '{1}' has been initialized .", _configuration.Name, Name);
                return;
            }

            //Create train directory
            if (FilePathUtil.CreateIfNotExists(Path))
            {
                _logger.LogDebug("Create train directory, [FilePool:'{0}',FilePool Path:'{1}',Train :'{2}'].", _configuration.Name, _configuration.Path, Index);
            }
            else
            {
                _logger.LogDebug("Create train '{0}' directory failed in  file pool '{1}'!", _configuration.Name, Name);
            }
            _initialized = true;
        }