Home > Net >  OpenFileDialog FolderBrowserDialog and demonstrate it, but can't open the file
OpenFileDialog FolderBrowserDialog and demonstrate it, but can't open the file

Time:01-29

According to the tutorial has written two programs, a use OpenFileDialog, a use FolderBrowserDialog, have succeeded in the pop-up folder box, but can't open the folder the file below, is this the two classes are only used for making a presentation? I hope I can open the program runs the local folders, and open the file below it, could you tell me me what should I do?

CodePudding user response:

What do you think about it, called open?

CodePudding user response:

The two just to choose the files and directories, need to do anything to you after ShowDialog ()==true after processing
Do you think about it, when you select a file, your program is expected to do? For instance you want to select files uploaded to the server, or you want to send this file in one line read, then save the database, if you do not say, procedure how to know what you want to do?

CodePudding user response:

 
Var DLG=new OpenFileDialog ();
If (DLG) ShowDialog==true)//WPF is a bool? Language is the winform, DialogResult
{
Var fileName=DLG. FileName;
//todo: do you know the user to select the file name, what do you want to do next?
//such as: printed to the console:
Console. WriteLine (fileName);
//other actions according to your needs for processing

}

CodePudding user response:

I don't know the building Lord want to do? But your request can write so,
 private void button1_Click (object sender, EventArgs e) 
{
OpenFileDialog OpenFileDialog=new OpenFileDialog ();
If (openFileDialog ShowDialog ()==DialogResult. OK)
{
String path=openFileDialog. FileName;
System. Diagnostics. Process. The Start (path);
}
}

CodePudding user response:

The
reference 3 floor ziqi0716 response:
 
Var DLG=new OpenFileDialog ();
If (DLG) ShowDialog==true)//WPF is a bool? Language is the winform, DialogResult
{
Var fileName=DLG. FileName;
//todo: do you know the user to select the file name, what do you want to do next?
//such as: printed to the console:
Console. WriteLine (fileName);
//other actions according to your needs for processing

}


Thanks for your reply, if I select a PDF file in folder dialog and tried to open it use foxit, so what is the code should be?

CodePudding user response:

your idea should be determined after the selected file or folder, will open,,,,
The two things just get path and file information to help you,,,

CodePudding user response:

 

Var DLG=new OpenFileDialog ();
If (DLG) ShowDialog==true)//WPF is a bool? Language is the winform, DialogResult
{
Var fileName=DLG. FileName;
//here you only know the path to the file, open the file to write code here, directly baidu a demo to know,

}

CodePudding user response:

refer to fifth floor electric aircraft manufacturers reply:
Quote: refer to the third floor ziqi0716 response:
 
Var DLG=new OpenFileDialog ();
If (DLG) ShowDialog==true)//WPF is a bool? Language is the winform, DialogResult
{
Var fileName=DLG. FileName;
//todo: do you know the user to select the file name, what do you want to do next?
//such as: printed to the console:
Console. WriteLine (fileName);
//other actions according to your needs for processing

}


Thanks for your reply, if I select a PDF file in folder dialog and tried to open it use foxit, so what is the code should be?

System. Diagnostics. Process. The Start (@ "c: \ myPDF PDF");
Or is this:
 
Var DLG=new OpenFileDialog ();
If (DLG) ShowDialog==true)//WPF is a bool? Language is the winform, DialogResult
{
Var fileName=DLG. FileName;
//todo: do you know the user to select the file name, what do you want to do next?
//such as: printed to the console:
Console. WriteLine (fileName);
//other actions according to your needs for processing
System. Diagnostics. Process. The Start (fileName);
}
  •  Tags:  
  • C#
  • Related