954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Copy a file to a specified folder

Hi all
I would just like to know how can I copy a file to a specified folder and the user chooses the file say via a openfiledialog. Now I cant specify a file because the folder is empty so I cant make use of the File.Copy method but there can be a vast amount of files copied to the folder. But not at once though. I have been busy searching the internet a while now and still I cant get something that tells me how to do it. Any help would be appreciated
Kind Regards
Weppies

Weppies
Newbie Poster
16 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

I'm not quite sure what your asking. Why can't you use File.Copy()?
You can select a file from a dialog using OpenFileDialog object, this will give you the file selected, having paths and file name then it's just a matter of copy...
You could use a function to copy like this:

public bool CopyFileTo(string filepath, string topath)
    {
        try
        {
            File.Copy(filepath, topath);
            return true;
        }
        catch (IOException ioe)
        {
            return false;
        }
    }
Rynkadink
Newbie Poster
24 posts since Feb 2011
Reputation Points: 28
Solved Threads: 2
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: