我正在尝试使用os.Replace()将文件从我的C盘移动到我的H盘.
代码如下:
func MoveFile(source string, destination string) {
err := os.Rename(source, destination)
if err != nil {
fmt.Println(err)
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我运行代码时,我收到以下错误:
rename C:\old\path\to\file.txt H:\new\path\to\file.txt: The system cannot move the file to a different disk drive.
Run Code Online (Sandbox Code Playgroud)
我在GitHub上发现了这个问题,指出了问题,但似乎他们不会更改此功能以允许它在不同的磁盘驱动器上移动文件.
我已经搜索了移动文件的其他可能性,但在标准文档或互联网中没有找到任何内容.
那么,我现在该怎么做才能在不同的磁盘驱动器上移动文件?
go ×1