learning. How to copy files and open programs

March 25, 2011 at 20:12:56
Specs: Win 7 Ultimate , 4.17Ghz 8GB ram
Hey I'm just starting to learn VB I'm using Visual basic studio 2010

I would like to know how to copy a specific file or folder to another location. and how to run a program.

Thanks for the help.


See More: learning. How to copy files and open programs

Report •


#1
March 26, 2011 at 14:18:45
I would like to know how to copy a specific file or folder to another location.
Use System.IO.File.Copy.

and how to run a program.
Use System.Diagnostics.Process.Start.

How To Ask Questions The Smart Way


Report •

#2
March 26, 2011 at 21:58:55
thanks for the link that kinda helps but like i said im just starting to learn can u give me a simple source code? that i can pick apart. I am not completely inexperienced at coding i know a lot of windows batch code and some html.

Report •

#3
March 27, 2011 at 03:41:46
Go back to the links I posted; both functions have examples given.

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
March 27, 2011 at 16:21:37
yeah i know they do but it seems like a lot of useless code. It looked really long to just copy a file? it was a good 40 lines.. is all the necessary? Sorry for being noobish but like i said im just trying to learn.

Report •

#5
March 27, 2011 at 17:02:57
The example moves all *.jpg files and all *.jpg files in a folder. It also "handles" exceptions.

Once you remove the whitespace, it's 34 lines, 8 of which are comments. Given the simplicity of the logic, 26 lines seems like a valid line count.

Don't be afraid of the debugger; run the example code, step by step, and observe what it's doing for yourself.

If you want a simpler example, here? (Might need to run elevated.)

File.Copy("C:\windows\system32\notepad.exe", "c:\notepad.exe")

How To Ask Questions The Smart Way


Report •

Ask Question