Answer the question
In order to leave comments, you need to log in
Strange work in Go [exec] or how to correctly execute an OS command?
cmd := exec.Command("cmd", "/C", "copy", "\""+filename+"\"", "\""+dest+"\"")
err := cmd.Run()
if err != nil {
log.Fatal(err)
}
Answer the question
In order to leave comments, you need to log in
If exec.Command receives arguments separately, then it must escape them on its own. Try removing the quotes from the last arguments.
Judging by the path / C - this is windows. On nix systems, the code looks like this exec.Command( "cp", filename, dest)
or exec.Command( "mv", filename, dest)
. I do not have windows to check, but try it exec.Command( "copy", filename, dest)
Well, you can manually
src, err::=os.Open(filename)
dst, err:=os.Create(dest)
size, err:= io.Copy(dst , src)
if err != nil {fmt.Println(err)}
fmt.Println("Размер", size)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question