Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
|
Split File into ChunksDemonstrates how to split a file into chunks.
CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @sTmp0 nvarchar(4000) DECLARE @fac int EXEC @hr = sp_OACreate 'Chilkat.FileAccess', @fac OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @success int -- Any type of file may be split. It doesn't matter if it's -- a binary file or a text file. DECLARE @fileToSplit nvarchar(4000) SELECT @fileToSplit = 'hamlet.xml' DECLARE @partPrefix nvarchar(4000) SELECT @partPrefix = 'hamlet' DECLARE @partExtension nvarchar(4000) SELECT @partExtension = 'spl' DECLARE @maxChunkSize int SELECT @maxChunkSize = 50000 DECLARE @destDirPath nvarchar(4000) SELECT @destDirPath = '.' -- Splits hamlet.xml into hamlet1.spl, hamlet2.spl, ... -- Output files are written to the current working directory. -- Each chunk will be 50000 bytes except for the last which -- will be the remainder. EXEC sp_OAMethod @fac, 'SplitFile', @success OUT, @fileToSplit, @partPrefix, @partExtension, @maxChunkSize, @destDirPath IF @success = 1 BEGIN PRINT 'Success.' END ELSE BEGIN EXEC sp_OAGetProperty @fac, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 END END GO |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.