Results 1 to 3 of 3

Thread: simulating VB's Dir function

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Sydney, Australia
    Posts
    74
    can I easily check for the existance of a certain file?

    with VB would just use Dir(FileName), an empty string returned would indicate that the file doesnt exist. Can I do something similar with C++?

  2. #2
    Guest
    use the undocumented SHFileExists function.

    here is the declaration in vb, if you can convert it to C++ good luck!

    Code:
    Private Declare Function SHFileExists Lib "shell32" Alias "#45" (ByVal szPath As String) As Long

  3. #3
    Lively Member
    Join Date
    Jun 2000
    Posts
    122
    Put this in to the OnClick Event of some control

    Code:
    AnsiString asFileName = FileSearch(Edit1->Text, GetCurrentDir());
    if (asFileName == "")
      Application->MessageBox(("Couldn't find " + Edit1->Text + ".").c_str(), "FileSearch Example", IDOK);
    else
      Application->MessageBox(("Found " + asFileName + ".").c_str(), "FileSearch Example", IDOK);
    I hope this works!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width