Saving a file to project folder and save its path

Total Post:30


 1743  View(s)
Rate this:

I am using visual studio 2010 (c#).

I would like to select a zip or rar file from my computer, save it to project folder and store its path to a variable.

I tried openfiledialog() but I couldn't solve it this way.

How can I do that?

  1. Re: Saving a file to project folder and save its path

    Hey Ida!

    private void button1_Click(object sender, EventArgs e)
                 var openFileDialog=new OpenFileDialog {Filter = @"Zip Files|*.zip|RAR Files|*.rar|All Files|*.*"};
                if (DialogResult.OK == openFileDialog.ShowDialog())
                    File.Copy(openFileDialog.FileName, Application.StartupPath + @"\"
                        + Path.GetFileName(openFileDialog.FileName));
                    yourvariable = Application.StartupPath + @"\"
                                   + Path.GetFileName(openFileDialog.FileName);

    your file will be copied to yourprojectname\yourprojectname\bin\Debug

      Modified On Mar-31-2018 04:23:01 AM


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.