C# windows 应用程序中的文件上传
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13377932/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
File Upload in C# windows Application
提问by Arianule
In my C# Windows application I want to upload a pdf file but in my toolbox I cannot find a FileUpload control.
在我的 C# Windows 应用程序中,我想上传一个 pdf 文件,但在我的工具箱中我找不到 FileUpload 控件。
How can I go about and uploading a pdf file in a C# windows application.?
如何在 C# windows 应用程序中上传 pdf 文件。?
regards
问候
采纳答案by Sylca
After you put a OpenFileDialog control on your form, let's say that you click a button and:
在窗体上放置 OpenFileDialog 控件后,假设您单击一个按钮并:
private void button1_Click(object sender, EventArgs e)
{
DialogResult result = openFileDialog1.ShowDialog();
if (result == DialogResult.OK) // Test result.
{
//Do whatever you want
//openFileDialog1.FileName .....
}
}
it goes something like this :-)
它是这样的:-)
回答by Legoless
You can use OpenFileDialogto get the filename of the file you need and then .NET Fileobject to read data from the file. You might need a control being able to display a PDF file. Please read the following:
您可以使用OpenFileDialog获取所需文件的文件名,然后使用 .NET File对象从文件中读取数据。您可能需要一个能够显示 PDF 文件的控件。请阅读以下内容:

