CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 25 of 25

Thread: Writing file

  1. #16
    Join Date
    Mar 2004
    Posts
    105
    Originally posted by Jeab.
    For "PathFileExists", is the syntax OK :
    if (PathFileExists(csFileName) == TRUE)
    {
    // Do smthg
    }

    The calling of this function might not be good cause "Undeclared identifier"...
    Do you have an idea ?

  2. #17
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430
    Do you ever read MSDN?
    PathFileExists
    Determines if a file exists.

    BOOL PathFileExists(
    LPCTSTR pszPath
    );

    Parameters
    pszPath
    Address of the file to verify.
    Return Values
    Returns TRUE if the file exists, or FALSE otherwise.

    Example
    .............
    Requirements
    Version 4.71 and later of Shlwapi.dll

    Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with Internet Explorer 4.0 or later).
    Windows 95/98: Requires Windows 98 (or Windows 95 with Internet Explorer 4.0 or later).
    Header: Declared in shlwapi.h.
    Import Library: shlwapi.lib.
    It means :
    a) you must have Internet Explorer 4.0 or later;
    b) you must "#include shlwapi.h";
    c) you must add shlwapi.lib in your Link "Objecl/Library modules..." settings;

  3. #18
    Join Date
    Mar 2004
    Posts
    105
    How to recover the address where the files are saved ?



    I use this code to open a CfileDialog for "Save as". And I want to see the ".mpg" files:

    CFileDialog cfDlg(FALSE, NULL, m_csPCFileName, OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER, "*.MPG ", NULL);

    But I can't see them...
    Last edited by Jeab.; April 15th, 2004 at 08:19 AM.

  4. #19
    Join Date
    Mar 2004
    Posts
    105
    Any idea ?

  5. #20
    Join Date
    Feb 2002
    Posts
    3,788
    try this:
    Code:
    CFileDialog  cfDlg(FALSE, NULL, m_csPCFileName, OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER, "Mpg Files (*.MPG)|*.MPG| ", NULL);
    PS: Please read MSDN. You are not at least trying here !

  6. #21
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430
    I use this code to open a CfileDialog for "Save as". And I want to see the ".mpg" files:

    CFileDialog cfDlg(FALSE, NULL, m_csPCFileName, OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER, "*.MPG ", NULL);

    But I can't see them...
    I am forced to repeat: Do you ever read MSDN?
    ........
    The lpszFilter parameter is used to determine the type of filename a file must have to be displayed in the file list box. The first string in the string pair describes the filter; the second string indicates the file extension to use. Multiple extensions may be specified using ‘;’ as the delimiter. The string ends with two ‘|’ characters, followed by a NULL character. You can also use a CString object for this parameter.

    For example, Microsoft Excel permits users to open files with extensions .XLC (chart) or .XLS (worksheet), among others. The filter for Excel could be written as:

    static char BASED_CODE szFilter[] =
    "Chart Files (*.xlc)|*.xlc|Worksheet Files (*.xls)|*.xls|Data Files (*.xlc;*.xls)|*.xlc; *.xls|All Files (*.*)|*.*||";
    In your case filter could look like:
    Code:
    szFilter[] =_T("MPG Files (*.MPG)|*.MPG|All Files (*.*)|*.*||");

  7. #22
    Join Date
    Sep 1999
    Location
    Germany, Hessen
    Posts
    226
    ... or only:

    CFileDialog cfDlg(FALSE, NULL, m_csPCFileName, OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER, _T("MPG Files (*.mpg)|*.mpg||") );


    There is no need to declare that static variable.

  8. #23
    Join Date
    Mar 2004
    Posts
    105
    Thank's it works weel...

    Sorry fot all these questions. I've one last:
    How is it possible to recover the file path from which the application is executed ?

  9. #24
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430
    Check out GetModuleFileName API

  10. #25
    Join Date
    Mar 2004
    Posts
    105
    Thank's for all of the informations you gave me
    You really helped me.

Page 2 of 2 FirstFirst 12

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

Featured