다음을 통해 공유


CanUseFileName

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at CanUseFileName.

Checks if a file exists. If the file exists and is not restricted, the wizard prompts the user to merge the code to be added to the existing file.

Syntax

  
      function CanUseFileName(   
   strFileName,   
   bCheckIfMidlHeader,   
   bCannotExist,   
   bSetMergeFlag    
);  

Parameters

strFileName
The name of the file to check.

bCheckIfMidlHeader
Set to true to check if file name is generated by MIDL.

bCannotExist
Set to true to check if the file name already exists and cannot be overwritten.

bSetMergeFlag
Set to true to include the MERG_FILE symbol, indicating that the user can merge the code to the existing file name.

Return Value

true if strFileName is unique, or if the code can be appended to the existing file; otherwise false.

Remarks

Call this function to check if a file name exists. If a file name exists, and it is not created by MIDL or is not otherwise restricted, the function prompts the user to merge the new code to the existing file.

If the file name does not exist and is not restricted, the file of the specified name is created.

If the file name is created by MIDL or is otherwise restricted, the wizard displays an error message.

Example

case "HTML_FILE":  
if (!HTML_FILE.disabled)  
   {  
   if (!window.external.FindSymbol("HTML_FILE_VALID"))  
      {  
      bValid = CanUseFileName(obj.value, false, true);  
      if (!bValid)  
      break;  
      window.external.AddSymbol("HTML_FILE_VALID", true)  
      }  
   }  
   bValid = window.external.ValidateFile(HTML_FILE.value, vsCMValidateFileExtHtml);  
   break;   

See Also

Customizing C++ Wizards with Common JScript Functions
JScript Functions for C++ Wizards
Creating a Custom Wizard
Designing a Wizard