从wpf中的本地计算机下载PDF文件

问题描述 投票:-8回答:1

单击该按钮,我需要下载/打开存储在WPF c#中本地计算机文件夹中的PDF文件。可以请给我一个代码吗?提前致谢。

c# wpf
1个回答
-1
投票

试试这个我觉得这就是你需要的东西c#

File.Copy("Path to Local File","Path where you want to download file");

EG

File.Copy("C://test.txt","D://test.txt");

如果你只是想打开一个文件

OpenFileDialog openFileDialog1 = new OpenFileDialog();

openFileDialog1.InitialDirectory = @"C:\";
openFileDialog1.Title = "Browse Files";
openFileDialog1.CheckFileExists = true;

openFileDialog1.CheckPathExists = true;
openFileDialog1.RestoreDirectory = true;

if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
    //Do you operation here
}
© www.soinside.com 2019 - 2024. All rights reserved.