In window forms, how to upload a file, I did not found any file upload control. Can you give me any reference? I want to store the document with in my systems drive. Thank you.
In Microsoft Forms, open the form you want to edit. Add new. Select More question types , and then select File upload. Note: File upload is only available when “Only people in my organization can respond” or “Specific people in my organization can respond” is the selected setting.
File Upload option is greyed out in the following conditions: Form is set to Anyone with the link can respond option. You are editing the form as collaborator.
You can put on your form button and create click handler to it with the following code:
private void buttonGetFile_Click(object sender, EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "Text files | *.txt"; // file types, that will be allowed to upload
dialog.Multiselect = false; // allow/deny user to upload more than one file at a time
if (dialog.ShowDialog() == DialogResult.OK) // if user clicked OK
{
String path = dialog.FileName; // get name of file
using (StreamReader reader = new StreamReader(new FileStream(path, FileMode.Open), new UTF8Encoding())) // do anything you want, e.g. read it
{
// ...
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With