Brett Barabash
BBarabash at TappeConstruction.com
Wed May 26 12:55:06 CDT 2004
How about: Public Sub SplitFile(ByVal strInputFile As String, _ ByVal strOutputDir As String, _ ByVal strFileBase As String, _ ByVal strFileExtension As String) Const cChunkSize = 1024 Const cFileSize = 1048576 Dim lngInFile As Long Dim lngOutFile As Long Dim lngRemaining As Long Dim lngChunkSize As Long Dim lngFileSize As Long Dim lngCtr As Long Dim strBuffer As String If Right$(strOutputDir, 1) <> "\" Then strOutputDir = strOutputDir & "\" End If If strFileExtension <> "" And Left$(strFileExtension, 1) <> "." Then strFileExtension = "." & strFileExtension End If lngInFile = FreeFile Open strInputFile For Binary As lngInFile lngOutFile = FreeFile lngCtr = 1 Open strOutputDir & strFileBase & lngCtr & strFileExtension For Binary As #lngOutFile lngRemaining = LOF(lngInFile) Do Until lngRemaining = 0 If lngRemaining > cChunkSize Then lngChunkSize = cChunkSize Else lngChunkSize = lngRemaining End If strBuffer = Space$(lngChunkSize) Get #lngInFile, , strBuffer Put #lngOutFile, , strBuffer lngRemaining = lngRemaining - lngChunkSize lngFileSize = lngFileSize + lngChunkSize If lngFileSize = cFileSize And lngRemaining > 0 Then Close #lngOutFile lngCtr = lngCtr + 1 Open strOutputDir & strFileBase & lngCtr & strFileExtension For Binary As #lngOutFile End If Loop Close #lngInFile Close #lngOutFile End Sub Public Sub ReassembleFiles(ByVal strOutputFile As String, _ ByVal strInputDir As String, _ ByVal strFileBase As String, _ ByVal strFileExtension As String) Const cChunkSize = 1024 Dim lngInFile As Long Dim lngOutFile As Long Dim lngRemaining As Long Dim lngChunkSize As Long Dim lngCtr As Long Dim strBuffer As String Dim strSrcFile As String If Right$(strInputDir, 1) <> "\" Then strInputDir = strInputDir & "\" End If If strFileExtension <> "" And Left$(strFileExtension, 1) <> "." Then strFileExtension = "." & strFileExtension End If lngOutFile = FreeFile Open strOutputFile For Binary As #lngOutFile lngInFile = FreeFile lngCtr = 1 strSrcFile = strInputDir & strFileBase & lngCtr & strFileExtension Do Until Dir$(strSrcFile) = "" Open strSrcFile For Binary As #lngInFile lngRemaining = LOF(lngInFile) Do Until lngRemaining = 0 If lngRemaining > cChunkSize Then lngChunkSize = cChunkSize Else lngChunkSize = lngRemaining End If strBuffer = Space$(lngChunkSize) Get #lngInFile, , strBuffer Put #lngOutFile, , strBuffer lngRemaining = lngRemaining - lngChunkSize Loop Close #lngInFile lngCtr = lngCtr + 1 strSrcFile = strInputDir & strFileBase & lngCtr & strFileExtension Loop Close #lngOutFile End Sub Alternatively, if the receiving side has shell access, they can reassemble the files using copy: copy /b c:\bitmaps\chunk1.doc + c:\bitmaps\chunk2.doc c:\bitmaps\myfile.tif. -----Original Message----- From: Jürgen Welz [mailto:jwelz at hotmail.com] Sent: Wednesday, May 26, 2004 11:37 AM To: accessd at databaseadvisors.com Subject: RE: [AccessD] File Slice/Splice Charlotte is correct. The IT people see Access as a program that creates files just like Notepad creates files. Since they installed Access 97, I have permission to use it to create mdb/mde files. Winzip or its ilk are not permitted. It is not possible to create a shortcut on the desktop, shell to DOS, create ODBC connections or install any software. It is also not possible to email certain files nor to access an email account from outside the offices except through Terminal Services, with no ability to save data to a disk at a remote machine. Only a few laptop users have access to a floppy drive at all and it is not possible for me to log on to the LAN with any laptop I bring on site. Any attempt to install any software on a laptop allowed on the system or on the terminal server is blocked and fails. If I want to email myself an Access application I'm working on, I currently have to break it into several dozen files with a few forms/reports/modules in each, rename them as doc files and reassemble the objects into a container offsite. This tactic does not work with large graphic files though. I've seen an mda at Dev's mvps.org site that purports to do this but I'm not sure I can get it up and running in the target environment. For this reason I'm looking for some straight forward File I/O code that will do the trick. They are starting to move to A2K3 and I've converted the application but my users cannot run it yet and they have not addressed self signing the 'macros' in Access. When they do, the jig may be up. Ciao Jürgen Welz Edmonton, Alberta jwelz at hotmail.com >From: "Charlotte Foust" <cfoust at infostatsystems.com> > >Arthur, > >I think the key issue was "getting it installed". Some systems are so >locked down that it isn't possible to get winzip installed on machines when >needed. > >Charlotte Foust > >-----Original Message----- >From: Arthur Fuller [mailto:artful at rogers.com] >Sent: Wednesday, May 26, 2004 7:27 AM >To: 'Access Developers discussion and problem solving' >Subject: RE: [AccessD] File Slice/Splice > > >Just out of curiosity, what is the security-paranoid distinction between >code you write and code that somebody known worldwide such as the author of >WinZip wrote? (I realize that you too are known world-wide, at least among >Access cognoscenti, but that wasn't my point.) Frankly, from my point of >view, I would sooner trust WinZip than my own efforts to do the same. After >all, they're on Version 9 or so! > >Arthur > >-----Original Message----- >From: accessd-bounces at databaseadvisors.com >[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Jürgen Welz >Sent: Wednesday, May 26, 2004 10:17 AM >To: accessd at databaseadvisors.com >Subject: [AccessD] File Slice/Splice > > >I'm looking for some VBA to cut a file into chunks of a size that can be > >emailed and then reassemble the full size at the destination. I've been > >playing with File I/O for a few hours, opening binary, reading into a >string >or byte array and then Output to new files but it looks like I'm getting a >few additional bytes in the reconstituted file. Presumably I'm adding some >delimiter to the file segments that mess up the file since it appears I'm >adding two bytes for each chunk plus another two overall. > >Does anyone have a solution? This is for sending large graphics files in >that security paranoid place I was formerly employed. They have an >attachment size limit of 5 megs and a bunch of 18 - 24 megabyte tiff files >that need to be sent out and, as usual, the IT department will not budge. >Winzip and it's disk spanning would be ok but there's no getting it >installed. > > >Ciao >Jürgen Welz >Edmonton, Alberta >jwelz at hotmail.com -------------------------------------------------------------------------------------------------------------------- The information in this email may contain confidential information that is legally privileged. The information is only for the use of the intended recipient(s) named above. If you are not the intended recipient(s), you are hereby notified that any disclosure, copying, distribution, or the taking of any action in regard to the content of this email is strictly prohibited. If transmission is incorrect, unclear, or incomplete, please notify the sender immediately. The authorized recipient(s) of this information is/are prohibited from disclosing this information to any other party and is/are required to destroy the information after its stated need has been fulfilled. Any views expressed in this message are those of the individual sender, except where the sender specifies and with authority, states them to be the views of Tappe Construction Co. This footer also confirms that this email message has been scanned for the presence of computer viruses.Scanning of this message and addition of this footer is performed by SurfControl E-mail Filter software in conjunction with virus detection software.