I have developed a program in an XP enviroment using Borland Builder 6. It has since been installed on a computer with Vista. The program opens text files which are stored in the root directory of the program. The pathname is set in global constants like "name.txt". This works fine in XP but in Vista the program runs OK at first, then loses the files when required a second time. I have traced all the files and they reside in the same directory as the exe file so the impression I have now is that Vista must be running the exe file from another position. At one point even data in the DB was disappearing and returning later, which suggests there were two instances of the database running, however I am still confused as to how this could happen, and haven't been able to recreate this problem yet to investigate further. I suppose my questions are has anyone else experienced something similar, is my compiler outdated for the Vista enviroment, have I forgotten something fundamental regarding streaming text files. I am not sure which direction to take to look for a solution. Regards Nev.

If you define relative file name (not full path - for example, "name.txt" only) then it's not a Vista problem. At run-time the current directory is not the same as exe module directory so the program can't access external files via relative file names.

Thanks, however hardcoding a full pathname doesn't seem to be a very elegant solution. I haven't experienced this before in XP where I have distributed several programs using relative pathnames without incident. Currently the problem is only appearing on the Vista platform and runs perfectly on my XP. How would I stream a file from an unknown directory? And I still don't comprehend why the program finds the file in the first instance and then loses it subsequently until I close and rerun the program. I shall investigate more so I can refine the symptoms better.

It appears as if you might have stumbled upon the virtualization feature of Windows Vista. Try looking it up on the MSDN.

Hey Thanks,
you may be onto something here so I shall do what you suggest. I haven't had a lot to do with Vista. Further to my prior posts, I have now borrowed a laptop with vista installed, installed my program and it seems to run fine so far. The only other thing I can think of is the program corrupted somehow during the install, but I do not have access to the computer to test this theory currently. I think I'll mark this as solved, thanks to you both for giving me direction. Much appreciated.

Better use GetModuleFileName Windows API function to get exe module full path. In that case you can safely access all files placed in the same directory. It's a classical approach (a very elegant solution ;) )...

ArkM, Although using GetModuleFileName won't help in this case. Unless I misunderstood the reams I read last night, Vista virtualization copies my text file to a virtual folder, so it turns out I was reading the original and writing to the copy, hence my thoughts about two instances running at once! I don't think it is supposed to work like that but in my case it certainly appeared to be. Once I get hold of the Vista laptop I can see if in fact this is the case.

This question has already been answered. Start a new discussion instead.