コード例 #1
0
        public void T5_GetDirectoryNameTest()
        {
            var path     = "foo/bar/someFile.dat";
            var filename = VirtualPath.GetDirectoryName(path);

            Assert.AreEqual("foo/bar", filename);
        }
コード例 #2
0
        public VirtualFile CreateFile(string filename)
        {
            var directoryName = VirtualPath.GetDirectoryName(filename);
            var directory     = getDirectoryFromPath(directoryName);

            return(directory.CreateFile(filename));
        }
コード例 #3
0
ファイル: VirtualFile.cs プロジェクト: sortaloc/DCNC-Tools
        public VirtualFile(string fileName, object file)
        {
            _innerFileEntry = file;

            // Since the path comes with microsoft-style separators, this will break
            // any non-microsoft operating system
            // Better replace them with the correct separator for the current OS
            var fullPath = fileName.Replace('\\', System.IO.Path.DirectorySeparatorChar);

            _path     = VirtualPath.GetDirectoryName(fullPath);
            _fileName = VirtualPath.GetFileName(fullPath);
        }
コード例 #4
0
        public async Task MoveDirectory(string sourcePath, string targetPath, Action <ProgressArgs> progressCallback, CancellationToken cancellationToken)
        {
            var directory = getDirectoryFromPath(sourcePath);
            var targetParentDirectoryName = VirtualPath.GetDirectoryName(targetPath);
            var targetDirectoryName       = VirtualPath.GetFileName(targetPath);
            var targetDirectory           = getDirectoryFromPath(targetParentDirectoryName);
            var movedDir = await directory.MoveTo(targetDirectory, progressCallback, cancellationToken);

            if (!cancellationToken.IsCancellationRequested)
            {
                movedDir.Name = targetDirectoryName;
            }
        }
コード例 #5
0
        public async Task CopyDirectory(string sourcePath, string targetPath, Action <ProgressArgs> progressCallback, CancellationToken cancellationToken)
        {
            var directory           = getDirectoryFromPath(sourcePath);
            var targetDirectoryPath = VirtualPath.GetDirectoryName(targetPath);
            var targetDirectoryName = VirtualPath.GetFileName(targetPath);
            var targetDirectory     = getDirectoryFromPath(targetDirectoryPath);
            var createdDirectory    = await directory.CopyTo(targetDirectory, progressCallback, cancellationToken);

            if (!cancellationToken.IsCancellationRequested)
            {
                createdDirectory.Name = targetDirectoryName;
            }
        }
コード例 #6
0
        public async Task CopyFile(string sourcePath, string targetPath, Action <ProgressArgs> progressCallback, CancellationToken cancellationToken)
        {
            var file           = getFileFromPath(sourcePath);
            var targetDirPath  = VirtualPath.GetDirectoryName(targetPath);
            var targetFilename = VirtualPath.GetFileName(targetPath);
            var targetDir      = getDirectoryFromPath(targetDirPath);
            var copiedFile     = await file.CopyTo(targetDir, progressCallback, cancellationToken);

            if (!cancellationToken.IsCancellationRequested)
            {
                copiedFile.Name = targetFilename;
            }
        }