Am a big beginner !
I want to browse file path in a text box ( i dot it yees ) !then now i want to copy and past this file from this source path to a path destination
Something like this

When i clic on add file , i browse my file
then , when i clic to connect i want to copy this file from this link in text box to a path destination .
It's possible ? i hope yes becase it's my only solution to have a copy
thanks u
Wim SturkenboomPosted Oct 20, 2014, 4:58 AM
// extract filename from path
System.IO.FileInfo fi = new System.IO.FileInfo(TextBox1.Text);
string filename = fi.Name;
// create destination filename by combining path and name
string yourdestination = yourdestinationpath + fi.Name;
// copy
System.IO.File.Copy(TextBox1.Text, yourdestination);
Note: make sure that yourdestinationpath ends with a path separator ('\' in windows).
Note: Both this and the previous post are not tested :-)
Nbl BzPosted Oct 20, 2014, 9:46 AM
It's woooooooork
without this line
string yourdestination = @"C:\Users\nab\Documents\Visual Studio 2012\Projects\proj\" + fi.Name;
I put the +fi.Name after
System.IO.File.Copy(textBox1.Text, @"C:\Users\nab\Documents\Visual Studio 2012\Projects\proj\" + fi.Name );
THANKS !!!
Nbl BzPosted Oct 20, 2014, 7:06 AM
private void button2_Click(object sender, EventArgs e)
{
System.IO.
FileInfo fi = new System.IO.FileInfo(textBox1.Text);
string filename = fi.Name;
string yourdestination = @"C:\Users\nab\Documents\Visual Studio 2012\Projects\proj\" + fi.Name;
System.IO.File.Copy(textBox1.Text, @"C:\Users\nab\Documents\Visual Studio 2012\Projects\proj\" );
my path exist :(
}
Wim SturkenboomPosted Oct 20, 2014, 6:27 AM
Nbl BzPosted Oct 20, 2014, 5:32 AM
Nbl BzPosted Oct 20, 2014, 4:43 AM
it generate exception that is a path no a file !! ?
Wim SturkenboomPosted Oct 20, 2014, 4:32 AM
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "c:\\" ;
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ; openFileDialog1.FilterIndex = 2 ;
openFileDialog1.RestoreDirectory = true ;
if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
TextBox1.Text = openFileDialog1.FileName;
}
For the copying, look at System.IO.File.Copy.
e.g.
System.IO.File.Copy(TextBox1.Text, yourdestination);