Jump to content
Sign in to follow this  
tannerli

CreateFile()?

Recommended Posts

tannerli

Already used Forum Search.... and also the helpfile

Am I terribly wrong now or does AutoIt lack a CreateFile() - Function.....?

I don't need to read/write it, it just has to exist....

I used

FileClose(FileOpen("command.fil", 1))

instead but I think there's an easier way....

greetings tannerli

Share this post


Link to post
Share on other sites
tannerli
:) sometime I think im a bit half-assed....

Share this post


Link to post
Share on other sites
poisonkiller

No you aren't, _FileCreate() works almost exactly as your method:

;===============================================================================
;
; Description:    Creates or zero's out the length of the file specified.
; Syntax:          _FileCreate( $sFilePath )
; Parameter(s):  $sFilePath - Path and filename of the file to be created
; Requirement(s):   None
; Return Value(s):  On Success - Returns 1
;                  On Failure - Returns 0 and sets:
;                               @error = 1: Error opening specified file
;                               @error = 2: File could not be written to
; Author(s):        Brian Keene <brian_keene at yahoo dot com>
; Note(s):        None
;
;===============================================================================
Func _FileCreate($sFilePath)
;==============================================
; Local Constant/Variable Declaration Section
;==============================================
    Local $hOpenFile
    Local $hWriteFile

    $hOpenFile = FileOpen($sFilePath, 2)

    If $hOpenFile = -1 Then
        SetError(1)
        Return 0
    EndIf

    $hWriteFile = FileWrite($hOpenFile, "")

    If $hWriteFile = -1 Then
        SetError(2)
        Return 0
    EndIf

    FileClose($hOpenFile)
    Return 1
EndFunc  ;==>_FileCreate

It's copied from File.au3.

Share this post


Link to post
Share on other sites
tannerli

Yeah, but I should have found it before.... I really looked in the help file

However, thx

greetings tannerli

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×