CreateUniqueFileInProjectLibrary
Creates a file with a unique name within the IDEA project library folder.
Compatibility
Available as of IDEA version 10.0
Syntax
CreateUniqueFileInProjectLibrary(libType as LibraryLocation, basePath as String, fileContent as String, encodingType as EncodingType)
Parameter
libType
Specifies the project library folder in which the file should be created.
The enum LibraryLocation is defined in Interop.COMMONIDEACONTROLSLib.dll:
namespace COMMONIDEACONTROLSLib
{
public enum LibraryLocation
{
EQUATIONS = 0,
IMPORT DEFINITIONS = 1,
MACROS = 2,
OTHER = 3,
SOURCE_FILES = 4,
PROJECT_SUMMARY = 5,
SMART_ANALYZER = 6,
CUSTOM_FUNCTION = 7,
EXPORTS = 8,
}
}
basePath
Template for creating the unique names.
basePath cannot be an absolute path but can be relative which is understood as relative to the specified library folder.
basePath may have an extension; unique file names thus created will have identical extensions.
Unique file names are constructed from basePath by edding the suffix "(n)" to the base file name with n starting from 2, i.e. possible suffixes are "(2)", "(3)" etc.
fileContent
Possible text to initialize the new file with. If this parameter is null or empty, an empty file is created.
encodingType
Specifies the encoding of the new file.
encodingType is defined like this:
namespace Audicon.SmartAnalyzer.Common.Types
{
///<summary>
Specifies the encoding that should be used by SmartAnalyzer methods when processing IDEA databases.
</summary>
[ComVisible(true)]
[Serializable]
public enum EncodingType
{
///<summary>
Use IDEA encoding (app standard)
///</summary>
IdeaDefault = 0,
///<summary>
Use ASCII
///</summary>
Ascii = 1,
///<summary>
Use Unicode
///</summary>
Unicode = 2
}
}
IdeaDefault: When this encoding is used, the encoding of the result file is defined by the IDEA encoding standard (ASCII or Unicode).
Ascii: The result file will have ASCII encoding.
Unicode: The result file will have Unicode encoding.
Return value
The method returns the full path of the newly created file; on server this path has UNC format.
Example
Sub Main
Dim SimpleCommands As Object
Set mc = SmartContext.MacroCommands
Set SimpleCommands = mc.SimpleCommands
Dim result As String
'2 is library folder "Macros"; 0 is encoding type IdeaDefault
result = SimpleCommands.CreateUniqueFileInProjectLibrary(2, "TestMacro.iss", "Hello", 0)
End Sub