How to set The Path?
-
Hi all, In my application I'm reading a file which is present in the project workspace . when the exe is copied to the desktop from the debug folder and run from there, I'm getting an error message which says,"THE FILE COULD NOT BE OPENED" How do i make the exe to look in to a specfic folder where i've kept the files? Thanks in Advance. Rajeev
-
Hi all, In my application I'm reading a file which is present in the project workspace . when the exe is copied to the desktop from the debug folder and run from there, I'm getting an error message which says,"THE FILE COULD NOT BE OPENED" How do i make the exe to look in to a specfic folder where i've kept the files? Thanks in Advance. Rajeev
rajeev82 wrote:
when the exe is copied to the desktop from the debug folder and run from there, I'm getting an error message which says,"THE FILE COULD NOT BE OPENED"
Yeah this will happen because the exe looks for files in it's path i.e the path from where it started up(not always) i.e. desktop. You've got to mention the filename path to solve this. Or else you can do this. Put the file where the exe is. Then you use this function to get the path of the exe:
GetModuleFileName(...)
Append this path to the file name. Then it will work always.Jesus Loves:rose:
--Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:
-
Hi all, In my application I'm reading a file which is present in the project workspace . when the exe is copied to the desktop from the debug folder and run from there, I'm getting an error message which says,"THE FILE COULD NOT BE OPENED" How do i make the exe to look in to a specfic folder where i've kept the files? Thanks in Advance. Rajeev
Hi, If you have a file other than your application's folder, then you should tell the exact path statically to your application. If you are storing the file in your application or temporary or system folders then you can use functions to get the file's folder. :cool: regards Vallikumar A
-
Hi all, In my application I'm reading a file which is present in the project workspace . when the exe is copied to the desktop from the debug folder and run from there, I'm getting an error message which says,"THE FILE COULD NOT BE OPENED" How do i make the exe to look in to a specfic folder where i've kept the files? Thanks in Advance. Rajeev
rajeev82 wrote:
How do i make the exe to look in to a specfic folder where i've kept the files? Thanks in Advance.
try
SetCurrentDirectory
andGetCurrentDirectory
api"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV
-
Hi all, In my application I'm reading a file which is present in the project workspace . when the exe is copied to the desktop from the debug folder and run from there, I'm getting an error message which says,"THE FILE COULD NOT BE OPENED" How do i make the exe to look in to a specfic folder where i've kept the files? Thanks in Advance. Rajeev
Hi rajeev how ru ? If u r using the CFile class then try this . CFile file; CFileException fe; if (!("C:\\Test.xml", CFile::modeCreate |CFile::modeReadWrite | CFile::shareExclusive, &fe)) { //handle the exception } Vikas Amin Embin Technology Bombay -- modified at 8:15 Wednesday 18th January, 2006