file.copy在同一目录中不起作用

时间:2018-01-02 23:34:32

标签: r

我正在尝试在同一目录中制作文件ABC的副本并重命名

   func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {

    guard let vcIndex = viewControllerList.index(of: viewController) else {
        return nil
    }

    let previousIndex = vcIndex - 1

    guard previousIndex >= 0 else {return nil}

    guard viewControllerList.count > previousIndex else {return nil}


    self.pageControl.currentPage = previousIndex

    return viewControllerList[previousIndex]

}

func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {

    guard let vcIndex = viewControllerList.index(of: viewController) else {return nil}

    let nextIndex = vcIndex + 1



    guard viewControllerList.count != nextIndex else {return nil}

    guard viewControllerList.count > nextIndex else {return nil}


    self.pageControl.currentPage = nextIndex

    return viewControllerList[nextIndex]

}

1 个答案:

答案 0 :(得分:0)

你可以试试这个:

todir<-tempdir()
file.copy(file.path(dirPath, fileABC), tempdir(), overwrite = FALSE)
file.rename(file.path(todir, fileABC),paste0(file.path(todir, fileABC),"_copy"))
file.copy(paste0(file.path(todir, fileABC),"_copy"), dirPath, overwrite = FALSE)
file.rename(paste0(file.path(dirPath, fileABC),"_copy"), file.path(dirPath, fileXYZ))