i have this code:
openFileDialog1.Filter = "csv files (*.dbf)|*.dbf";
openFileDialog1.FilterIndex = 1;
openFileDialog1.RestoreDirectory = true;
openFileDialog1.FileName = "";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
dbf_File = openFileDialog1.FileName;
}
in dbf_File i get all the file path and name (c:\MyDir\MyFile.dbf
)
i need only the name - MyFile.dbf
To extract filename from the file, we use “GetFileName()” method of “Path” class. This method is used to get the file name and extension of the specified path string. The returned value is null if the file path is null.
If you want the ls command output to only contain file/directory names and their respective sizes, then you can do that using the -h option in combination with -l/-s command line option.
If you want to display only the filename, you can use basename command. find infa/bdm/server/source/path -type f -iname "source_fname_*. txt" Shell command to find the latest file name in the command task!
Only the file name (with extension):
dbf_File = System.IO.Path.GetFileName(dbf_File);
Only the containing directory:
string dbf_Path = System.IO.Path.GetDirectoryName(dbf_File);
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