C# 将文件保存到项目文件夹并保存其路径
我正在使用VisualStudio2010C 我想从我的计算机中选择一个zip或rar文件,将其保存到项目文件夹并将其路径存储到变量 我试过openfiledialog,但用这种方法解决不了 我该怎么做C# 将文件保存到项目文件夹并保存其路径,c#,C#,我正在使用VisualStudio2010C 我想从我的计算机中选择一个zip或rar文件,将其保存到项目文件夹并将其路径存储到变量 我试过openfiledialog,但用这种方法解决不了 我该怎么做 private void button1_Click(object sender, EventArgs e) { var openFileDialog=new OpenFileDialog {Filter = @"Zip Files|*.zip|RAR
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);
}
}
您的文件将被复制到yourprojectname\yourprojectname\bin\Debug