On Fri, 2018-05-04 at 03:30 +0000, Vino via Digitalmars-d-learn wrote: > Hi All, > > Request you help on the below code, the below code always state > the file does not exist even if the file do exist. > > Code: > > import core.stdc.stdlib: exit; > import std.stdio; > import std.file; > import std.path; > > auto osSwitch () { > string ConfigFile; > version (Windows) { ConfigFile = absolutePath(`.\nasconfig.txt`);
`./nasconfig.txt` perhaps: Linux uses / (as does Windows in fact) for directory separator. > } else version (Linux) { ConfigFile = > absolutePath(`nasconfig.txt`); } > return ConfigFile; > } > void main () { > auto ConfigFile = osSwitch; > if (!ConfigFile.exists) { writeln("The Configuration File ", > buildNormalizedPath(ConfigFile), " do to exist, Terminating the > execution.."); exit(-1);} > else { writeln(ConfigFile); } > } > > From, > Vino.B > -- Russel. ========================================== Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Road m: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk
signature.asc
Description: This is a digitally signed message part