Return FileName Only when using OpenFileDialog

后端 未结 8 785
孤独总比滥情好
孤独总比滥情好 2020-12-06 04:34

I am using the following method to browse for a file:

    OpenFileDialog.ShowDialog()
    PictureNameTextEdit.Text = OpenFileDialog.FileName
<
相关标签:
8条回答
  • 2020-12-06 05:08

    C++ code for obtain filename and complete path in OpenFileDialog:

    textBox1->Text = OpenFileDialog1->FileName; //complete path textBox1->Text = System::IO::Path::GetFileName(OpenFileDialog1->FileName); //filename

    0 讨论(0)
  • //Following code return file name only 
    
    string[] FileFullPath;
    string FileName;
    objOpenFileDialog.Title = "Select Center Logo";
    objOpenFileDialog.ShowDialog();
    
    FileFullPath = objOpenFileDialog.FileNames[0].ToString().Split('\\');
    FileName = FileFullPath[FileFullPath.Length - 1]; //return only File Name
    
    //Use following code if u want save other folder , 
    // following code save file to CenterLogo  folder which inside bin folder//
    
    System.IO.File.Copy(OFD.FileName, Application.StartupPath + 
    "/CenterLogo/" + FileName, true);
    
    0 讨论(0)
提交回复
热议问题