Click here to Skip to main content
15,888,968 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I want to save selected file in other folder in windows application.

Here what i want to do.
I have taken one OpenFileDialog. When i select any file using that dialog, the whole file path shows in textbox as per below code

C#
DialogResult result= openFileDialog1.ShowDialog();
            textBox1.Text = openFileDialog1.FileName.ToString();


Now i have one other button with 'Upload' title. Now i want when i click on 'Upload' button my selected file should be save another folder where i wish(e.g. C:\UploadedImage\);

Please anyone can help me in this issue. I really need it.

Thanks and Regards

Suman Zalodiya
Posted
Updated 18-Sep-11 8:05am
v2

Try this file copy method will copy your image to new location with a new name
C#
string fulllocimage = openFileDialog1.FileName;
File.Copy(fulllocimage, @"C:\UploadedImage\" + NewImageName);
 
Share this answer
 
Comments
Herman<T>.Instance 18-Sep-11 14:06pm    
and the @C"\UploadedImage\" part could be placed as key in the config file
Suman Zalodiya 18-Sep-11 14:07pm    
Thanks for your reply.

It's not working. Please can you give me one example?
Arun Kumar K S 18-Sep-11 14:21pm    
May be your C drive permission problem try to save it into another drive
Suman Zalodiya 18-Sep-11 14:25pm    
Thanks Arun it's working.

Many many thanks
Arun Kumar K S 18-Sep-11 14:28pm    
Copy(string sourceFileName, string destFileName);
Finally i stop with

string fullpath=openDialog1.FileName;
string extension=Path.GetExtension(fullpath);
File.Copy(fullpath,@"D:\UploadedImages\" + "hello" + extension);

Thanks to all of you for reply.
 
Share this answer
 

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