Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET3.5 C#
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
 
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 11-Sep-12 2:54am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

See this small snippet:
System.IO.File.Copy("C:\\Temp\\Test.zip", "D:\\Test.zip");
  Permalink  
Comments
Manohar Khillare at 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 at 11-Sep-12 9:04am
   
Then it seems you don't have this drive/folder.
Kuthuparakkal at 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 at 11-Sep-12 10:16am
   
5'ed!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Copying file is rather simple:
http://www.dotnetperls.com/file-copy[^]
 
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"));
    }
}
  Permalink  

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



Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 11 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid