-1

I have a button that opens a file in a exe, what I would like to do is check to make sure this file exist before starting the exe. How could I accomplish this? Any help would be greatly appreciated.

I am a tad rusty on my C++ and this is a legacy application using C++ 6.0 and windows xp...

here is my code ..

void CJunkView::OnCadkeyButton() 

  { 
     CString year = "Desktop";
     CString fileName = "x.prt";
     CString fileToOpen = "\"C:\\Documents and settings\\Administrator\\" + year +"\\" + fileName + "\"";
     CString exePath = "\"C:\\CK19\\Ckwin.exe\"";
     CString cmd = "start " + exePath + ", " + fileToOpen;
     system (cmd.GetBuffer(cmd.GetLength() + 1));

  }
Snowman288
  • 97
  • 1
  • 2
  • 9

1 Answers1

0

As you seem to use the Microsoft C++ API, take a look at CFile and moreover the GetStatus method : https://msdn.microsoft.com/fr-fr/library/fa0hc0ht.aspx The method may return False if your file doesn't exist