Click here to Skip to main content
15,174,232 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have button named "btnSend", and i have some files include in my project such as file called "Manifold", so i want to click this button to copy this files to path which i select ..... thank you

What I have tried:

CommonOpenFileDialog dialog = new CommonOpenFileDialog();
            dialog.IsFolderPicker = true;
            string strPath = "Any Path";

            if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
                strPath = dialog.FileName;

            string strDist = Properties.Resources.In_Out_Manifold.ToString();

            File.Copy(strDist, strPath + "\\" + "In-Out-Manifold.SLDPRT");
Updated 10-Sep-21 2:51am
Richard MacCutchan 10-Sep-21 7:09am
What happens when you run the code?
OriginalGriff 10-Sep-21 7:11am
What does it do that you didn't expect, or not do that you did?
What have you tried to do to find out why?
Are there any error messages, and if so, where and when? What did you do to make them happen?

This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
Use the "Improve question" widget to edit your question and provide better information.
BillWoodruff 10-Sep-21 23:52pm
I think Dave's answer meets your needs For another technique which you could use to copy bitmaps and other types:

1 solution

You cannot use File.Copy to copy a file out of Resources.

What you get from resources is a string, not a file. Why are you calling .ToString() on a string?

You have to write the string to a file, which you cannot do with File.Copy. You have to use normal file writing methods, like:
string content = Properties.Resources.TextFile1;
File.WriteAllText(filepath, content);
BillWoodruff 10-Sep-21 23:39pm

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