AutoIt: Създаване на файл с определен размер

Публикувано: 09.08.13, 21:52:33 | Автор: ArMeN | Видяна: 999 | Редактирано: 19.07.16, 21:15:07

#include <Process.au3>
$FilePath = "D:\123.txt"
$Size = 1024*1024 ; 1mb
If _RunDOS('fsutil file createnew "' & $filepath & '" ' & $size) Then
MsgBox(0,"Ошибка", "Файл уже существует либо не может быть создан")
Else
MsgBox(0,"Ошибка", "Файл успешно создан")
EndIf


#include <WinApi.au3>
$hFile = _WinAPI_CreateFile("D:\123.rar", 3, 6)
_WinAPI_SetFilePointer($hFile, 1024*1024, 1) ; 1mb
_WinAPI_SetEndOfFile($hFile)
_WinAPI_CloseHandle($hFile)


$N = 12345678; Number of bytes
$sPath = 'C:\somefile.txt'
$sText = ''
For $i = 1 to $N
$sText &= '0'
Next
FileWrite($sPath, $sText)


$iByte = 1024 * 1024; 1Мб
$sFile = @ScriptDir & '\test.tst'
$sTest = ''

For $i = 1 To $iByte
$sTest &= '0'
Next
$hFile = FileOpen($sFile, 2)
FileWrite($hFile, $sTest)
FileClose($hFile)
MsgBox(64, 'Info', FileGetSize($sFile))


Източник

Не сте влезли в акаунта си за да коментирате.


 

Няма коментари.