c# cant locate images -


i have piece of code

string [] imglocation =     directory.getfiles(@"assets\cards\pack_classic\", " *.png",                        searchoption.topdirectoryonly); 

it's supposed give me location of image files inside folder.however doesn't work @ all, gives me 0 strings. why ? images location : _poker\poker\bin\debug\assets\cards\pack_classic

getfiles needs absolute file path in order work in reliable way. reflection (through assembly class)

string exedir = path.getdirectoryname(assembly.getentryassembly().location); string fullpath = path.combine(exedir, @"assets\cards\pack_classic"); string[] imglocation = directory.getfiles(fullpath, "*.png", searchoption.topdirectoryonly); 

exedir bin\debug folder.


note: getfiles works relative paths starting @ current working directory. problem don't know 1 is! can different directory executable resides.


Comments