Tải bản đầy đủ (.pdf) (6 trang)

AutoIT Help part 31 pdf

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (75.52 KB, 6 trang )

hàm sẽ copy trước rồi mới xóa

sử dụng filemove thay cho filerename

flag 9 = flag 8 + flag 1

một số thuwocj tính của file có thể làm hàm bị lỗi
Related
FileCopy, FileDelete, FileRecycle, DirMove
Example

FileMove("C:\foo.au3", "D:\mydir\bak.au3")

; Second example:
; uses flags '1' (owerwriting) and '8' (autocreating target dir structure) together
; moves all txt-files from temp to txtfiles and prechecks if
; target directory structure exists, if not then automatically creates it
FileMove(@TempDir & "\*.txt", @TempDir & "\TxtFiles\", 9)




Function Reference
FileOpen
mở một file để sẵn sàng đọc hoặc ghi dl
FileOpen ( "filename", mode )
Parameters
filename đường dẫn tới file cần mở
mode xác định mục đích mở file
0 = mở ra để đọc
1 = để ghi thêm vào cuối file


2 = để ghi (xóa hết dữ liệu cũ)
4 = chế độ đọc "tươi"
8 = tạo ra file nếu file yêu cầu ko tồn tại.
16 = đọc ghi kiểu nhị phân
32 = đọc ghi kiểu Unicode UTF16 Little Endian
64 = đọc ghi kiểu Unicode UTF16 Big Endian
128 = đọc ghi kiểu Unicode UTF8

Return Value
Success:

trả lại
handle
của file
Failure:

trả lại -1 nếu sảy ra bất kì lỗi nào

Remarks
một tập tin chỉ có thể đọc hoặc ghi, ko thể thực hiện cả 2 đc

một số thuộc tính của file có thể ảnh hưởng tới kết quả của hàm

khi mở file ra để ghi thì file sẽ đc tạo mới nếu chưa tồn tại

khi hoàn tất việc đọc và ghi thì ta cần thiêts phải đóng file lại = hàm fileclose

chế độ mặc định khi viết văn bản là ANSI - sử dụng flag unicode để thay đổi điều
này.


flag 9 = flag 8 + flag 1
Related
FileClose, FileReadLine, FileWriteLine, FileRead
Example

$file = FileOpen("test.txt", 0)

; Check if file opened for reading OK
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf

FileClose($file)


; Another sample which automatically creates the directory structure
$file = FileOpen("test.txt", 10) ; which is similar to 2 + 8 (erase + create dir)

If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf

FileClose($file)



Function Reference
FileOpenDialog

tạo ra một hộp thoại để lựa chọn file.
FileOpenDialog ( "title", "init dir", "filter" [, options [, "default name" [, hwnd]]] )
Parameters
title tên cửa sổ
init dir thư mục chủ để tìm và chọn file trong đó
filter định dạng kiểu file nào đc phép chọn vd "All (*.*)" hay "Text files
(*.txt)" hoặc có thể lựa chọn kiểu file "All (*.*)|Text files (*.txt)"
options
1 = file phải tồn tại
2 = đường dẫn phải tồn tại
4 = cho phép chọn nhiều file
8 = hiện thông báo nhắc nhở "tạo mới file" nếu file đc chọn ko tồn tại

default
name
tên mặc định
hwnd handle của GUI mẹ

Return Value
Success:

trả lại đường dẫn đầy dủ của file đc chọn, ở flag=4 thì trả lại "đường dẫn
tới thư mục|file1|file2| "
Failure:

Sets @error = 1.

Remarks
!



Related
FileSaveDialog, FileSelectFolder, StringSplit
Example

$message = "Hold down Ctrl or Shift to choose multiple files."

$var = FileOpenDialog($message, @WindowsDir & "\", "Images (*.jpg;*.bmp)", 1
+ 4 )

If @error Then
MsgBox(4096,"","No File(s) chosen")
Else
$var = StringReplace($var, "|", @CRLF)
MsgBox(4096,"","You chose " & $var)
EndIf


; Multiple filter group
$message = "Hold down Ctrl or Shift to choose multiple files."

$var = FileOpenDialog($message, @WindowsDir & "", "Images
(*.jpg;*.bmp)|Videos (*.avi;*.mpg)", 1 + 4 )

If @error Then
MsgBox(4096,"","No File(s) chosen")
Else
$var = StringReplace($var, "|", @CRLF)
MsgBox(4096,"","You chose " & $var)
EndIf






Function Reference
FileRead
đọc kí tự trong file.
FileRead ( filehandle or "filename" [, count] )
Parameters
filehandle handle file, giá trị đc trả lại bởi fileopen
count
số kí tự muốn đọc trong file, hay số byte muốn đọc trong kiểu mở nhị
phân (mặc định là đọc tất)


Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×