How can I return in for each a directories files/folders without the directory path included?

Hello,
As the topic

variable type - String

problem

Thanks

Hi @Marcin,

use

  1. path.getfilename(yourStringfullpath) fro with extension of file.
  2. Path.GetFileNameWithoutExtension(yourStringFullPath) for without extenstion.

try and let me know.

Happy coding
Avi

Hi @Avi7

thanks but there was a problem

that’s why i used Directory.GetDirectories

Thank You for all

@Marcin I think u have created dbNameList variable of array of string change it to string type.

@Manjuts90

I have many files in my folder (path). I must have String.

@Marcin

  1. Use Directory.Getfiles(“ur folder path”) and assign it string array variable.
  2. Use for each loop input as above array.
  3. Path.GetFileNameWithoutExtension(useloop variable) assign that value to ur required variable.

@Manjuts90

I don’t know if I understood you well, but I hope I did what you wanted:

dbNameList(String)

(assign) dbNameList = Directory.GetFiles(folder path)

(foreach) item in dbNameList

(Type into)
Path.GetFileNameWithoutExtension(dbNameList)

error
Unfortunately, it receives error - “1-dimensional String ” cannot be converted to “String”
variable type String

@Marcin

image

Change the marked variable in pic with item.ToString

THANKS!! @Manjuts90

1 Like