Click here to Skip to main content
11,576,963 members (52,364 online)
Rate this: bad
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
Please Sign up or sign in to vote.

Solution 1

See this small snippet:
System.IO.File.Copy("C:\\Temp\\", "D:\\");
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
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
0 Sergey Alexandrovich Kryukov 251
1 DamithSL 155
2 Abhinav S 130
3 OriginalGriff 105
4 Afzaal Ahmad Zeeshan 85
0 OriginalGriff 715
1 Sergey Alexandrovich Kryukov 631
2 Abhinav S 528
3 F-ES Sitecore 420
4 Suvendu Shekhar Giri 365

Advertise | Privacy | Mobile
Web03 | 2.8.150603.1 | Last Updated 11 Sep 2012
Copyright © CodeProject, 1999-2015
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