Answers for "open file dialog asp.net"

VBA
4

c# open file dialog

OpenFileDialog dialog = new OpenFileDialog();
if (DialogResult.OK == dialog.ShowDialog()) 
{
    string path = dialog.FileName;
}
Posted by: Guest on July-16-2020
1

open file dialog c#

var fileContent = string.Empty;
var filePath = string.Empty;

using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
    openFileDialog.InitialDirectory = "c:\";
    openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
    openFileDialog.FilterIndex = 2;
    openFileDialog.RestoreDirectory = true;

    if (openFileDialog.ShowDialog() == DialogResult.OK)
    {
        //Get the path of specified file
        filePath = openFileDialog.FileName;

        //Read the contents of the file into a stream
        var fileStream = openFileDialog.OpenFile();

        using (StreamReader reader = new StreamReader(fileStream))
        {
            fileContent = reader.ReadToEnd();
        }
    }
}

MessageBox.Show(fileContent, "File Content at path: " + filePath, MessageBoxButtons.OK);
Posted by: Guest on September-27-2020
0

open file dialog in vb.net

'How to open the file path in Visual Basic
OpenFileDialog1.Filter = "TEXT FILE | *.txt |PDF FILE |.pdf |ALL FILES |*.*"
If OpenFileDialog1.ShowDialog = DialogResult.OK Then
	For x = 0 To OpenFileDialog1.FileNames.Count - 1
		MsgBox(OpenFileDialog1.FileNames(x))
	Next
End If
Posted by: Guest on September-04-2020
0

how to use open file dialog in c# windows application

OpenFileDialog dialog = new OpenFileDialog();
if (DialogResult.OK == dialog.ShowDialog()) 
{
    string path = dialog.FileName;
}



// or
var fileContent = string.Empty;
var filePath = string.Empty;

using (OpenFileDialog openFileDialog = new OpenFileDialog())
{
    openFileDialog.InitialDirectory = "c:\";
    openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
    openFileDialog.FilterIndex = 2;
    openFileDialog.RestoreDirectory = true;

    if (openFileDialog.ShowDialog() == DialogResult.OK)
    {
        //Get the path of specified file
        filePath = openFileDialog.FileName;

        //Read the contents of the file into a stream
        var fileStream = openFileDialog.OpenFile();

        using (StreamReader reader = new StreamReader(fileStream))
        {
            fileContent = reader.ReadToEnd();
        }
    }
}

MessageBox.Show(fileContent, "File Content at path: " + filePath, MessageBoxButtons.OK);
Posted by: Guest on February-25-2021

Code answers related to "VBA"

Browse Popular Code Answers by Language