Click here to Skip to main content
12,827,765 members (45,188 online)
Rate this:
Please Sign up or sign in to vote.
See more: .NET3.5 C# .NET
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 3:54am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

See this small snippet:
System.IO.File.Copy("C:\\Temp\\", "D:\\");
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
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Copying file is rather simple:[^]

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

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100