Click here to Skip to main content
15,887,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my project i browse zip file from local drive. i want it should be store or copy on specific location like "D:\\". Below is my code

C#
private void button2_Click(object sender, EventArgs e)
       {
           OpenFileDialog open1 = new OpenFileDialog();
           // file filters
           open1.Filter = "Document Files(*.RAR)|*.RAR";
           if (open1.ShowDialog() == DialogResult.OK)
           {

               // document file path
               txtdocumentuploda.Text = open1.FileName;

           }
       }
Posted

See this small snippet:
System.IO.File.Copy("C:\\Temp\\Test.zip", "D:\\Test.zip");
 
Share this answer
 
Comments
Manohar Khillare 11-Sep-12 8:59am    
they show me error Could not find a part of the path 'D:\'.
System.IO.File.Copy(txtdocumentuploda.Text, "D:\\");
JF2015 11-Sep-12 9:04am    
Then it seems you don't have this drive/folder.
Kuthuparakkal 11-Sep-12 10:14am    
Specify full path as given by JF2015...
File.Copy(arg1, arg2) here arg1 and arg2 respesents full path. Not directory.
Espen Harlinn 11-Sep-12 10:16am    
5'ed!
Copying file is rather simple:
http://www.dotnetperls.com/file-copy[^]

C#
using System;
using System.IO;

class Program
{
    static void Main()
    {
    // Figure 1
    // Copy one file to a non-existent location
    File.Copy("file-a.txt", "file-new.txt");

    // Display the contents of both files
    Console.WriteLine(File.ReadAllText("file-a.txt"));
    Console.WriteLine(File.ReadAllText("file-new.txt"));
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900