开发者

C# getting the filename of a file you open in the openfiledialog

开发者 https://www.devze.com 2023-04-02 10:35 出处:网络
Is there a way to get the file name of a file you open using the openfiledialog in C#? I need this because, the user is going to open an image file, but then the image file is added to a listbox(using

Is there a way to get the file name of a file you open using the openfiledialog in C#? I need this because, the user is going to open an image file, but then the image file is added to a listbox(using its filename), then can be selected开发者_C百科 for display in a picturebox. Having trouble finding a solution for this. Cheers.


Use OpenFileDialog.FileName:

if(openFileDialog.ShowDialog() == DialogResult.OK)
{
    InsertIntoList(openFileDialog.FileName);
}


Have you tried using openfiledialog.FileName property?


use openFileDialog.SafeFileName to get just the name of the file

openFileDialog.FileName returns the full path to the file

0

精彩评论

暂无评论...
验证码 换一张
取 消