VB快速创建超大文件

VB中使用以下代码可以快速、几乎是瞬间创建出一个2GB大小的文件。

ps.不要做坏事喔-

Dim path As String
path = InputBox("Folder", "2GB file creator", "C:\2gb.dat")

Dim fn As Integer
fn = FreeFile

Open path For Binary As #fn
Seek #fn, &H7FFFFFFE
Put #fn, , CByte(0)
Close #fn

MsgBox "Done"


14 thoughts on “VB快速创建超大文件

  1. Pingback: satellite service
  2. 来个VC SDK的.. :)
    HANDLE hFile = ::CreateFile(_T(“C:\\xxoo.txt”),
    GENERIC_READ | GENERIC_WRITE,
    FILE_SHARE_READ, NULL, CREATE_ALWAYS,
    FILE_ATTRIBUTE_NORMAL, NULL);
    if(INVALID_HANDLE_VALUE != hFile)
    {
    LARGE_INTEGER liFileSize;
    liFileSize.QuadPart = 0x100000000;
    if(::SetFilePointerEx(hFile, liFileSize, NULL, FILE_BEGIN))
    {
    ::SetEndOfFile(hFile);
    }
    ::CloseHandle(hFile);
    }

发表评论

电子邮件地址不会被公开。 必填项已用*标注