Click here to Skip to main content
15,904,153 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: read a file using Readfile() Pin
chandu00420-Jun-09 2:04
chandu00420-Jun-09 2:04 
GeneralRe: read a file using Readfile() Pin
Rajesh R Subramanian20-Jun-09 2:09
professionalRajesh R Subramanian20-Jun-09 2:09 
GeneralRe: read a file using Readfile() Pin
chandu00420-Jun-09 2:15
chandu00420-Jun-09 2:15 
AnswerRe: read a file using Readfile() Pin
Ozer Karaagac20-Jun-09 14:25
professionalOzer Karaagac20-Jun-09 14:25 
GeneralRe: read a file using Readfile() Pin
rahuljin20-Jun-09 1:55
rahuljin20-Jun-09 1:55 
GeneralRe: read a file using Readfile() Pin
chandu00420-Jun-09 2:06
chandu00420-Jun-09 2:06 
GeneralRe: read a file using Readfile() Pin
rahuljin20-Jun-09 3:21
rahuljin20-Jun-09 3:21 
AnswerRe: read a file using Readfile() Pin
krmed20-Jun-09 3:42
krmed20-Jun-09 3:42 
I've read through this whole thread, and here's the problem...

If you open a file with just the filename, the system looks for that file in the "current directory". The problem is that the current directory when you first start the app (from windows explorer) will be the directory containing the app. However, if you browse to a different folder (with CFileDialog for example), that changes the "current directory".

To resolve this, you can find the directory that your app is in by using
GetModuleFileName
and then you can use
PathRemoveFileSpec
to remove the app name. Next use
PathAppend
to add the name of the file you want. Now you have the complete path to your file in your app directory, regardless of what the "current directory" is.

Hope that helps.

Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

GeneralRe: read a file using Readfile() Pin
rahuljin20-Jun-09 8:13
rahuljin20-Jun-09 8:13 
GeneralRe: read a file using Readfile() Pin
krmed20-Jun-09 9:34
krmed20-Jun-09 9:34 
GeneralRe: read a file using Readfile() Pin
rahuljin20-Jun-09 22:01
rahuljin20-Jun-09 22:01 
Questionincrease the size of the DialogBox during RunTime Pin
p_196020-Jun-09 0:27
p_196020-Jun-09 0:27 
AnswerRe: increase the size of the DialogBox during RunTime Pin
Sarath C20-Jun-09 0:35
Sarath C20-Jun-09 0:35 
GeneralRe: increase the size of the DialogBox during RunTime Pin
p_196020-Jun-09 0:42
p_196020-Jun-09 0:42 
GeneralRe: increase the size of the DialogBox during RunTime Pin
p_196020-Jun-09 1:08
p_196020-Jun-09 1:08 
AnswerRe: increase the size of the DialogBox during RunTime Pin
Ozer Karaagac20-Jun-09 15:21
professionalOzer Karaagac20-Jun-09 15:21 
AnswerRe: increase the size of the DialogBox during RunTime Pin
Rajesh R Subramanian20-Jun-09 3:02
professionalRajesh R Subramanian20-Jun-09 3:02 
GeneralRe: increase the size of the DialogBox during RunTime Pin
p_196020-Jun-09 18:05
p_196020-Jun-09 18:05 
QuestionHow to close the window? Pin
Nikesh Jagtap19-Jun-09 22:07
Nikesh Jagtap19-Jun-09 22:07 
AnswerRe: How to close the window? Pin
Rajesh R Subramanian19-Jun-09 22:44
professionalRajesh R Subramanian19-Jun-09 22:44 
QuestionHow to close the window? Pin
Nikesh Jagtap19-Jun-09 22:01
Nikesh Jagtap19-Jun-09 22:01 
AnswerRe: How to close the window? Pin
Sarath C20-Jun-09 0:30
Sarath C20-Jun-09 0:30 
QuestionComboBox in WIN32 programming. Pin
birajendu19-Jun-09 20:49
birajendu19-Jun-09 20:49 
AnswerRe: ComboBox in WIN32 programming. Pin
Sarath C20-Jun-09 0:20
Sarath C20-Jun-09 0:20 
GeneralRe: ComboBox in WIN32 programming. Pin
birajendu20-Jun-09 9:03
birajendu20-Jun-09 9:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.