简体   繁体   中英

How do I copy a directory?

I want to copy one directory from one location to another but while copying I am getting an error message:

" Could not complete operation on some files and directories. See the Data property of the exception for more details. " i don't know what is the problem

I tried:

Microsoft.VisualBasic.FileIO.FileSystem.CopyDirectory(FolderBrowserDialog1.SelectedPath, System.IO.Path.Combine(curDir, filename.Name))

and

My.Computer.FileSystem.CopyDirectory(FolderBrowserDialog1.SelectedPath, System.IO.Path.Combine(curDir, filename.Name))

But I am still getting same message .

Any pointers on how to get around this?

Thanks.

You could try using

Process.StartInfo.Filename = "xcopy"
Process.StartInfo.Arguments = String.Format("{0} {1} {2}", sourcedir, destdir, xcopyflags)
Process.Start()

If you're not sure of the flags or usage you can open a command prompt and type

xcopy /?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM