---
product: Chilkat
product_version: 11.7.0
language: asp
language_label: Classic ASP
class: FileAccess
license: free
deprecated: false
reference_html: https://www.chilkatsoft.com/refdoc/asp_FileAccessRef.html
---
# Chilkat FileAccess — Classic ASP — v11.7.0

> Chilkat 11.7.0 · language=asp · class=FileAccess
> Other versions: replace `11.7.0` in this URL. Other languages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/<lang>/classes/FileAccess.md`.
> Language-wide rules (install, unlock, error model, strings/bytes): `https://www.chilkatsoft.com/ai-docs/v/11.7.0/asp/guide.md`.

## Purpose

**Read, write, compare, copy, split, inspect, and manage files and paths.**

`Chilkat.FileAccess` provides general-purpose file-system utilities for applications that need direct control over files, directories, paths, timestamps, and low-level file operations. It can read, write, append, seek, compare, copy, rename, delete, split, reassemble, and inspect files, and also includes helpers for directory operations, path parsing, symbolic links, temporary filenames, block-based reading, fragment scanning, text replacement, and open-file access.

**Read and write files**

Load or save text and binary files, append data, replace file contents, and work with explicit character encodings when needed.

**File management**

Copy, rename, delete, compare, split, reassemble, and inspect files using straightforward file-system utility methods.

**Directories and paths**

Create, remove, check, and work with directories, and use path helpers to extract filenames, extensions, directory names, and related path parts.

**Open-file operations**

Open files for lower-level reading or writing, seek within files, read blocks, and process large files without loading everything at once.

**Timestamps and metadata**

Get or set file times, inspect sizes and existence, and use metadata helpers when coordinating file processing workflows.

**Special file utilities**

Generate temporary filenames, work with symbolic links, scan for byte fragments, and perform text replacement in files.

**Common pattern:** Use `FileAccess` for local file-system tasks that are outside the scope of a specific protocol class. It is especially useful for preparing files before upload, saving downloaded data, comparing or splitting files, reading large files in blocks, manipulating paths, or performing small filesystem operations without using platform-specific APIs.

For an extended overview, see [FileAccess Class Overview](https://www.chilkatsoft.com/fileaccess_class_overview.asp).

## Object creation, unlocking and error handling

**Object Creation**

```visual-basic
set fileAccess = Server.CreateObject("Chilkat.FileAccess")

' ... use fileAccess ...

set fileAccess = Nothing
```

Classic ASP creates Chilkat objects with `Server.CreateObject`. The registered Chilkat ActiveX must match the bitness of the IIS application pool: a pool with *Enable 32-Bit Applications* set to True needs the 32-bit ActiveX, otherwise the 64-bit ActiveX. To bind to a specific major version of Chilkat, append the major version number to the ProgID, such as `Server.CreateObject("Chilkat.FileAccess.11")` for Chilkat v11.\*.\*.

VBScript requires `set` when assigning an object, so the signatures on this page show `set x = obj.Method(...)` for methods that return a Chilkat object; test the result with `Is Nothing`, since a method that fails to return an object returns `Nothing`. A method with no return value is called as a statement without parentheses (`obj.Method arg1, arg2`). Boolean properties, arguments and return values are integers in the ActiveX: pass `1` or `0`, and test success with `= 1`. Byte arrays are Variant arrays and can be sent with `Response.BinaryWrite`. Asynchronous (*\*Async*) methods and event callbacks are not used from Classic ASP.

Call `Global.UnlockBundle` once at the start of the program, before using this or any other Chilkat class. Any string unlocks a fully functional 30-day trial; a purchased unlock code is used in production. See `guide.md` for the exact code in Classic ASP.

How failure is reported depends on the method's return type and is stated in the note under each method below. In every case the diagnostic text is in the `LastErrorText` property of the object whose method was called.

## Members common to every Chilkat class

Documented once per language in `common-members.md`; listed here so this page is self-contained.

| Property | Signature | Access | Meaning |
|---|---|---|---|
| `DebugLogFilePath` | `fileAccess.DebugLogFilePath ' String` | read/write | If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. |
| `LastBinaryResult` | `fileAccess.LastBinaryResult ' Variant (read-only)` | read-only | This property is mainly used in SQL Server stored procedures to retrieve binary data from the last method call that returned binary data. |
| `LastErrorHtml` | `fileAccess.LastErrorHtml ' String (read-only)` | read-only | Provides HTML-formatted information about the last called method or property. |
| `LastErrorText` | `fileAccess.LastErrorText ' String (read-only)` | read-only | Provides plain text information about the last called method or property. |
| `LastErrorXml` | `fileAccess.LastErrorXml ' String (read-only)` | read-only | Provides XML-formatted information about the last called method or property. |
| `LastMethodSuccess` | `fileAccess.LastMethodSuccess ' Long` | read/write | Indicates the success or failure of the most recent method call: `1` means success, `0` means failure. |
| `LastStringResult` | `fileAccess.LastStringResult ' String (read-only)` | read-only | In SQL Server stored procedures, this property holds the string return value of the most recent method call that returns a string. |
| `LastStringResultLen` | `fileAccess.LastStringResultLen ' Long (read-only)` | read-only | The length, in characters, of the string contained in the LastStringResult property. |
| `VerboseLogging` | `fileAccess.VerboseLogging ' Long` | read/write | If set to `1`, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. |
| `Version` | `fileAccess.Version ' String (read-only)` | read-only | Version of the component/library, such as "10.1.0" |

## Member index

| Member | Kind | Signature |
|---|---|---|
| `CurrentDir` | property, read-only | `fileAccess.CurrentDir ' String (read-only)` |
| `EndOfFile` | property, read-only | `fileAccess.EndOfFile ' Long (read-only)` |
| `FileOpenError` | property, read-only | `fileAccess.FileOpenError ' Long (read-only)` |
| `FileOpenErrorMsg` | property, read-only | `fileAccess.FileOpenErrorMsg ' String (read-only)` |
| `LockFileOnOpen` | property, read/write | `fileAccess.LockFileOnOpen ' Long` |
| `AppendAnsi` | method | `success = fileAccess.AppendAnsi(text) ' Long (1/0)` |
| `AppendBd` | method | `success = fileAccess.AppendBd(bd) ' Long (1/0)` |
| `AppendSb` | method | `success = fileAccess.AppendSb(sb, charset) ' Long (1/0)` |
| `AppendText` | method | `success = fileAccess.AppendText(str, charset) ' Long (1/0)` |
| `AppendUnicodeBOM` | method | `success = fileAccess.AppendUnicodeBOM() ' Long (1/0)` |
| `AppendUtf8BOM` | method | `success = fileAccess.AppendUtf8BOM() ' Long (1/0)` |
| `DirAutoCreate` | method | `success = fileAccess.DirAutoCreate(filePath) ' Long (1/0)` |
| `DirCreate` | method | `success = fileAccess.DirCreate(dirPath) ' Long (1/0)` |
| `DirDelete` | method | `success = fileAccess.DirDelete(dirPath) ' Long (1/0)` |
| `DirEnsureExists` | method | `success = fileAccess.DirEnsureExists(dirPath) ' Long (1/0)` |
| `DirExists` | method | `success = fileAccess.DirExists(dirPath) ' Long (1/0)` |
| `FileClose` | method | `fileAccess.FileClose` |
| `FileContentsEqual` | method | `success = fileAccess.FileContentsEqual(filePath1, filePath2) ' Long (1/0)` |
| `FileCopy` | method | `success = fileAccess.FileCopy(existingFilepath, newFilepath, failIfExists) ' Long (1/0)` |
| `FileDelete` | method | `success = fileAccess.FileDelete(filePath) ' Long (1/0)` |
| `FileExists` | method | `success = fileAccess.FileExists(filePath) ' Long (1/0)` |
| `FileExists3` | method | `n = fileAccess.FileExists3(path) ' Long` |
| `FileOpen` | method | `success = fileAccess.FileOpen(filePath, accessMode, shareMode, createDisposition, attributes) ' Long (1/0)` |
| `FileRead` | method | `bytes = fileAccess.FileRead(maxNumBytes) ' Variant` |
| `FileReadBd` | method | `success = fileAccess.FileReadBd(maxNumBytes, binData) ' Long (1/0)` |
| `FileRename` | method | `success = fileAccess.FileRename(existingFilepath, newFilepath) ' Long (1/0)` |
| `FileSeek` | method | `success = fileAccess.FileSeek(offset, origin) ' Long (1/0)` |
| `FileSize` | method | `n = fileAccess.FileSize(filePath) ' Long` |
| `FileSizeStr` | method | `str = fileAccess.FileSizeStr(filePath) ' String` |
| `FileType` | method | `n = fileAccess.FileType(path) ' Long` |
| `FileWrite` | method | `success = fileAccess.FileWrite(data) ' Long (1/0)` |
| `FileWriteBd` | method | `success = fileAccess.FileWriteBd(binData, offset, numBytes) ' Long (1/0)` |
| `GenBlockId` | method | `str = fileAccess.GenBlockId(index, length, encoding) ' String` |
| `GetDirectoryName` | method | `str = fileAccess.GetDirectoryName(path) ' String` |
| `GetExtension` | method | `str = fileAccess.GetExtension(path) ' String` |
| `GetFileName` | method | `str = fileAccess.GetFileName(path) ' String` |
| `GetFileNameWithoutExtension` | method | `str = fileAccess.GetFileNameWithoutExtension(path) ' String` |
| `GetFileTimeStr` | method | `str = fileAccess.GetFileTimeStr(path, which) ' String` |
| `GetNumBlocks` | method | `n = fileAccess.GetNumBlocks(blockSize) ' Long` |
| `GetTempFilename` | method | `str = fileAccess.GetTempFilename(dirPath, prefix) ' String` |
| `OpenForAppend` | method | `success = fileAccess.OpenForAppend(filePath) ' Long (1/0)` |
| `OpenForRead` | method | `success = fileAccess.OpenForRead(filePath) ' Long (1/0)` |
| `OpenForReadWrite` | method | `success = fileAccess.OpenForReadWrite(filePath) ' Long (1/0)` |
| `OpenForWrite` | method | `success = fileAccess.OpenForWrite(filePath) ' Long (1/0)` |
| `ReadBinaryToEncoded` | method | `str = fileAccess.ReadBinaryToEncoded(filePath, encoding) ' String` |
| `ReadBlock` | method | `bytes = fileAccess.ReadBlock(blockIndex, blockSize) ' Variant` |
| `ReadBlockBd` | method | `success = fileAccess.ReadBlockBd(blockIndex, blockSize, bd) ' Long (1/0)` |
| `ReadEntireFile` | method | `bytes = fileAccess.ReadEntireFile(filePath) ' Variant` |
| `ReadEntireTextFile` | method | `str = fileAccess.ReadEntireTextFile(filePath, charset) ' String` |
| `ReadNextFragment` | method | `n = fileAccess.ReadNextFragment(startAtBeginning, beginMarker, endMarker, charset, sb) ' Long` |
| `ReassembleFile` | method | `success = fileAccess.ReassembleFile(partsDirPath, partPrefix, partExtension, reassembledFilename) ' Long (1/0)` |
| `ReplaceStrings` | method | `n = fileAccess.ReplaceStrings(filePath, charset, existingString, replacementString) ' Long` |
| `SetCurrentDir` | method | `success = fileAccess.SetCurrentDir(dirPath) ' Long (1/0)` |
| `SetFileTimes` | method | `success = fileAccess.SetFileTimes(filePath, createTime, lastAccessTime, lastModTime) ' Long (1/0)` |
| `SetLastModified` | method | `success = fileAccess.SetLastModified(filePath, lastModified) ' Long (1/0)` |
| `SplitFile` | method | `success = fileAccess.SplitFile(fileToSplit, partPrefix, partExtension, partSize, destDir) ' Long (1/0)` |
| `SymlinkCreate` | method | `success = fileAccess.SymlinkCreate(targetPath, linkPath) ' Long (1/0)` |
| `SymlinkTarget` | method | `str = fileAccess.SymlinkTarget(linkPath) ' String` |
| `TreeDelete` | method | `success = fileAccess.TreeDelete(path) ' Long (1/0)` |
| `Truncate` | method | `success = fileAccess.Truncate() ' Long (1/0)` |
| `WriteEntireFile` | method | `success = fileAccess.WriteEntireFile(filePath, fileData) ' Long (1/0)` |
| `WriteEntireTextFile` | method | `success = fileAccess.WriteEntireTextFile(filePath, textData, charset, includedPreamble) ' Long (1/0)` |

Deprecated members are listed at the end of this file with their replacements; do not use them in new code.

## Properties

### FileAccess.CurrentDir

`Chilkat 11.7.0 · asp · FileAccess · CurrentDir · property · read-only`

```visual-basic
fileAccess.CurrentDir  ' String (read-only)
```

Returns the current working directory of the calling process. Relative file and directory paths are resolved against this process-wide working directory.

**Process-wide setting:** The working directory belongs to the process, not to an individual `FileAccess` object. Changing it can therefore affect relative-path behavior elsewhere in the application.

### FileAccess.EndOfFile

`Chilkat 11.7.0 · asp · FileAccess · EndOfFile · property · read-only`

```visual-basic
fileAccess.EndOfFile  ' Long (read-only)
```

Returns `1` when the currently open file is positioned at end-of-file; otherwise returns `0`.

**Open-file state:** This property applies to the file opened by `OpenForRead`, `OpenForWrite`, `OpenForReadWrite`, `OpenForAppend`, or `FileOpen`.

### FileAccess.FileOpenError

`Chilkat 11.7.0 · asp · FileAccess · FileOpenError · property · read-only`

```visual-basic
fileAccess.FileOpenError  ' Long (read-only)
```

Provides the detailed open-error code from the most recent call to `FileOpen`, `OpenForRead`, `OpenForWrite`, `OpenForReadWrite`, or `OpenForAppend`.

| Code | Meaning |
| :--- | :--- |
| `0` | Success; no open error. |
| `1` | Access denied. |
| `2` | File not found. |
| `3` | General, non-specific open error. |
| `4` | File already exists. |
| `5` | The path refers to a directory and the requested access involves writing. |
| `6` | Too many symbolic links were encountered while resolving the path. |
| `7` | The process already has the maximum number of files open. |
| `8` | The pathname is too long. |
| `9` | The system-wide limit on open files has been reached. |
| `10` | The pathname refers to a device special file for which no corresponding device exists. |
| `11` | Insufficient kernel memory was available. |
| `12` | A file was to be created, but the containing device has no space available. |
| `13` | A pathname component expected to be a directory is not a directory. |
| `14` | The regular file is too large to be opened because of an operating-system limitation. |
| `15` | The path is on a read-only filesystem and write access was requested. |

**Use with FileOpenErrorMsg:** `FileOpenError` is useful for programmatic handling; `FileOpenErrorMsg` provides the corresponding human-readable message.

### FileAccess.FileOpenErrorMsg

`Chilkat 11.7.0 · asp · FileAccess · FileOpenErrorMsg · property · read-only`

```visual-basic
fileAccess.FileOpenErrorMsg  ' String (read-only)
```

Returns the human-readable message corresponding to `FileOpenError` for the most recent file-open attempt.

### FileAccess.LockFileOnOpen

`Chilkat 11.7.0 · asp · FileAccess · LockFileOnOpen · property · read/write · since 9.5.0.80`

```visual-basic
fileAccess.LockFileOnOpen  ' Long
```

**Windows only.** If `1`, `OpenForAppend`, `OpenForRead`, `OpenForReadWrite`, and `OpenForWrite` request exclusive access to the file. Other processes are prevented from opening the file until `FileClose` releases the handle. The default is `0`.

**File sharing:** Windows file sharing is established when the file handle is opened. Set this property before calling an `OpenFor*` method.

## Methods

### FileAccess.AppendAnsi

`Chilkat 11.7.0 · asp · FileAccess · AppendAnsi · method`

```visual-basic
success = fileAccess.AppendAnsi(text)  ' Long (1/0)
```

Appends `text` to the currently open file after converting the string to the legacy ANSI character encoding used by Chilkat for the platform.

**Character encoding:** Use `AppendText` or `AppendSb` when an explicit encoding such as `utf-8` is preferred.

Returns 1 for success, 0 for failure.

### FileAccess.AppendBd

`Chilkat 11.7.0 · asp · FileAccess · AppendBd · method · since 9.5.0.76`

```visual-basic
success = fileAccess.AppendBd(bd)  ' Long (1/0)
```

Appends all bytes contained in `bd` to the currently open file without text conversion.

Returns 1 for success, 0 for failure.

### FileAccess.AppendSb

`Chilkat 11.7.0 · asp · FileAccess · AppendSb · method · since 9.5.0.76`

```visual-basic
success = fileAccess.AppendSb(sb, charset)  ' Long (1/0)
```

Appends the text contained in `sb` to the currently open file using the character encoding specified by `charset`.

Returns 1 for success, 0 for failure.

### FileAccess.AppendText

`Chilkat 11.7.0 · asp · FileAccess · AppendText · method`

```visual-basic
success = fileAccess.AppendText(str, charset)  ' Long (1/0)
```

Appends `str` to the currently open file after encoding the text with the character set named by `charset`, such as `utf-8` or `iso-8859-1`.

Returns 1 for success, 0 for failure.

### FileAccess.AppendUnicodeBOM

`Chilkat 11.7.0 · asp · FileAccess · AppendUnicodeBOM · method`

```visual-basic
success = fileAccess.AppendUnicodeBOM()  ' Long (1/0)
```

Appends the UTF-16 little-endian byte-order mark to the currently open file. The two bytes written are `FF FE`.

**BOM placement:** A BOM normally belongs at the beginning of a text file. This method appends bytes at the current write position, so call it before writing text when creating a new UTF-16LE file.

Returns 1 for success, 0 for failure.

### FileAccess.AppendUtf8BOM

`Chilkat 11.7.0 · asp · FileAccess · AppendUtf8BOM · method`

```visual-basic
success = fileAccess.AppendUtf8BOM()  ' Long (1/0)
```

Appends the UTF-8 byte-order mark to the currently open file. The three bytes written are `EF BB BF`.

**UTF-8 BOM:** A UTF-8 BOM is optional. Some software uses it as an encoding signature, while other software expects BOM-less UTF-8.

Returns 1 for success, 0 for failure.

### FileAccess.DirAutoCreate

`Chilkat 11.7.0 · asp · FileAccess · DirAutoCreate · method`

```visual-basic
success = fileAccess.DirAutoCreate(filePath)  ' Long (1/0)
```

Ensures that the directory portion of `filePath` exists. Any missing parent directories are created; the final path component is treated as a filename and is not created as a directory.

**Difference from DirEnsureExists:** Use `DirAutoCreate` when you have a file path. Use `DirEnsureExists` when the argument itself is a directory path.

Returns 1 for success, 0 for failure.

### FileAccess.DirCreate

`Chilkat 11.7.0 · asp · FileAccess · DirCreate · method`

```visual-basic
success = fileAccess.DirCreate(dirPath)  ' Long (1/0)
```

Creates the directory specified by `dirPath`. Parent directories must already exist; use `DirEnsureExists` when missing parent directories should also be created.

Returns 1 for success, 0 for failure.

### FileAccess.DirDelete

`Chilkat 11.7.0 · asp · FileAccess · DirDelete · method`

```visual-basic
success = fileAccess.DirDelete(dirPath)  ' Long (1/0)
```

Deletes the directory specified by `dirPath`. The directory must be empty; use `TreeDelete` to recursively delete a directory and its contents.

Returns 1 for success, 0 for failure.

### FileAccess.DirEnsureExists

`Chilkat 11.7.0 · asp · FileAccess · DirEnsureExists · method`

```visual-basic
success = fileAccess.DirEnsureExists(dirPath)  ' Long (1/0)
```

Ensures that the complete directory path `dirPath` exists, creating missing directories along the path as needed.

Returns 1 for success, 0 for failure.

### FileAccess.DirExists

`Chilkat 11.7.0 · asp · FileAccess · DirExists · method · since 10.0.0`

```visual-basic
success = fileAccess.DirExists(dirPath)  ' Long (1/0)
```

Returns `1` if `dirPath` exists as a directory; otherwise returns `0`.

### FileAccess.FileClose

`Chilkat 11.7.0 · asp · FileAccess · FileClose · method`

```visual-basic
fileAccess.FileClose
```

Closes the currently open file and releases its operating-system file handle. Any exclusive lock obtained through `LockFileOnOpen` is released at this time.

### FileAccess.FileContentsEqual

`Chilkat 11.7.0 · asp · FileAccess · FileContentsEqual · method`

```visual-basic
success = fileAccess.FileContentsEqual(filePath1, filePath2)  ' Long (1/0)
```

Compares `filePath1` and `filePath2` byte-for-byte and returns `1` only when their contents are identical. File sizes are compared first; when sizes match, the files are compared incrementally rather than being loaded entirely into memory.

**Binary comparison:** The comparison is byte-oriented. Text encodings, line-ending conventions, and Unicode normalization are not interpreted or normalized.

### FileAccess.FileCopy

`Chilkat 11.7.0 · asp · FileAccess · FileCopy · method`

```visual-basic
success = fileAccess.FileCopy(existingFilepath, newFilepath, failIfExists)  ' Long (1/0)
```

Copies `existingFilepath` to `newFilepath`. If `failIfExists` is `1` and the destination already exists, the copy fails instead of overwriting it.

Returns 1 for success, 0 for failure.

### FileAccess.FileDelete

`Chilkat 11.7.0 · asp · FileAccess · FileDelete · method`

```visual-basic
success = fileAccess.FileDelete(filePath)  ' Long (1/0)
```

Deletes the file specified by `filePath`.

Returns 1 for success, 0 for failure.

### FileAccess.FileExists

`Chilkat 11.7.0 · asp · FileAccess · FileExists · method`

```visual-basic
success = fileAccess.FileExists(filePath)  ' Long (1/0)
```

Returns `1` if `filePath` exists; otherwise returns `0`. Use `FileExists3` when the application must distinguish "does not exist" from "could not determine because of an error."

### FileAccess.FileExists3

`Chilkat 11.7.0 · asp · FileAccess · FileExists3 · method · since 9.5.0.45`

```visual-basic
n = fileAccess.FileExists3(path)  ' Long
```

Checks whether `path` exists and returns a three-state result: `1` if it exists, `0` if it does not exist, and `-1` if Chilkat could not determine the result because of permissions or another filesystem error.

### FileAccess.FileOpen

`Chilkat 11.7.0 · asp · FileAccess · FileOpen · method`

```visual-basic
success = fileAccess.FileOpen(filePath, accessMode, shareMode, createDisposition, attributes)  ' Long (1/0)
```

**Windows-specific low-level open.** Opens `filePath` using arguments modeled after the Win32 `CreateFile` API. For portable code, prefer `OpenForRead`, `OpenForWrite`, `OpenForReadWrite`, or `OpenForAppend`.

| Category | Common values |
| --- | --- |
| Access | `GENERIC_READ = 0x80000000`, `GENERIC_WRITE = 0x40000000` |
| Sharing | `FILE_SHARE_READ = 0x1`, `FILE_SHARE_WRITE = 0x2` |
| Disposition | `CREATE_NEW=1`, `CREATE_ALWAYS=2`, `OPEN_EXISTING=3`, `OPEN_ALWAYS=4`, `TRUNCATE_EXISTING=5` |

**Open failures:** When this method fails, inspect `FileOpenError` and `FileOpenErrorMsg` for the reason.

Returns 1 for success, 0 for failure.

### FileAccess.FileRead

`Chilkat 11.7.0 · asp · FileAccess · FileRead · method`

```visual-basic
bytes = fileAccess.FileRead(maxNumBytes)  ' Variant
```

Reads up to `maxNumBytes` bytes from the current file position and advances the file position by the number of bytes actually read. An empty byte array is returned on error.

**End of file:** A short read is normal near end-of-file. Use `EndOfFile` when the caller needs to distinguish EOF state explicitly.

Returns a zero-length byte array (as a Variant) on failure.  
An empty array will have a UBound of -1 meaning 0 elements.

### FileAccess.FileReadBd

`Chilkat 11.7.0 · asp · FileAccess · FileReadBd · method · since 9.5.0.64`

```visual-basic
success = fileAccess.FileReadBd(maxNumBytes, binData)  ' Long (1/0)
```

Reads up to `maxNumBytes` bytes from the current file position and appends the bytes to `binData`. The file position advances by the number of bytes read.

**Destination behavior:** Existing bytes already present in `binData` are preserved; newly read bytes are appended.

Returns 1 for success, 0 for failure.

### FileAccess.FileRename

`Chilkat 11.7.0 · asp · FileAccess · FileRename · method`

```visual-basic
success = fileAccess.FileRename(existingFilepath, newFilepath)  ' Long (1/0)
```

Renames or moves `existingFilepath` to `newFilepath` using the local filesystem.

Returns 1 for success, 0 for failure.

### FileAccess.FileSeek

`Chilkat 11.7.0 · asp · FileAccess · FileSeek · method`

```visual-basic
success = fileAccess.FileSeek(offset, origin)  ' Long (1/0)
```

Moves the current file position by `offset` bytes relative to `origin`.

|  |  |
| --- | --- |
| `0` | Offset from the beginning of the file. |
| `1` | Offset from the current file position. |
| `2` | Offset from end-of-file; negative offsets are commonly used. |

**Random access:** Seeking changes where the next read or write occurs; it does not itself read, write, or resize the file.

Returns 1 for success, 0 for failure.

### FileAccess.FileSize

`Chilkat 11.7.0 · asp · FileAccess · FileSize · method`

```visual-basic
n = fileAccess.FileSize(filePath)  ' Long
```

Returns the file size in bytes as a signed 32-bit integer.

**Failure returns 0:** If the size cannot be obtained (for example, the file does not exist or cannot be accessed), the return value is `0`, which is the same as for an empty file. To detect failure, use `FileSizeStr`, which fails instead of returning a size, or check first with `FileExists3`.

**Large files:** A signed 32-bit result cannot represent files larger than approximately 2 GB. Use `FileSize64` or `FileSizeStr` for large files.

### FileAccess.FileSizeStr

`Chilkat 11.7.0 · asp · FileAccess · FileSizeStr · method · since 9.5.0.80`

```visual-basic
str = fileAccess.FileSizeStr(filePath)  ' String
```

Returns the size of `filePath` in bytes as a decimal string. This avoids the range limitation of a 32-bit integer return value.

Returns `Nothing` on failure

### FileAccess.FileType

`Chilkat 11.7.0 · asp · FileAccess · FileType · method · since 9.5.0.77`

```visual-basic
n = fileAccess.FileType(path)  ' Long
```

Examines `path` and classifies the filesystem entry.

|  |  |
| --- | --- |
| `-1` | Unable to determine because of permissions or another error. |
| `0` | Does not exist. |
| `1` | Regular file. |
| `2` | Directory. |
| `3` | Symbolic link. |
| `4` | Windows shortcut. |
| `99` | Another filesystem type. |

**Future values:** Additional file-type codes may be added in future versions as needed.

### FileAccess.FileWrite

`Chilkat 11.7.0 · asp · FileAccess · FileWrite · method`

```visual-basic
success = fileAccess.FileWrite(data)  ' Long (1/0)
```

Writes all bytes in `data` at the current file position and advances the position accordingly.

Returns 1 for success, 0 for failure.

### FileAccess.FileWriteBd

`Chilkat 11.7.0 · asp · FileAccess · FileWriteBd · method · since 9.5.0.64`

```visual-basic
success = fileAccess.FileWriteBd(binData, offset, numBytes)  ' Long (1/0)
```

Writes bytes from `binData` to the currently open file. `offset` selects the starting byte within the `BinData`; `numBytes` selects how many bytes to write. Set both to `0` to write the entire `BinData`, or set `numBytes` to `0` to write all remaining bytes beginning at `offset`.

Returns 1 for success, 0 for failure.

### FileAccess.GenBlockId

`Chilkat 11.7.0 · asp · FileAccess · GenBlockId · method · since 9.5.0.58`

```visual-basic
str = fileAccess.GenBlockId(index, length, encoding)  ' String
```

Generates a fixed-width decimal block identifier from `index`, padded to `length` characters, and then encodes those bytes using `encoding` (for example `base64`, `hex`, or `ascii`). This utility was originally added for block-oriented uploads such as Azure Blob block uploads.

**Ordering:** Fixed-width decimal identifiers preserve numeric ordering when identifiers are compared lexically, provided the chosen width is large enough for all indexes.

Returns `Nothing` on failure

### FileAccess.GetDirectoryName

`Chilkat 11.7.0 · asp · FileAccess · GetDirectoryName · method · since 9.5.0.64`

```visual-basic
str = fileAccess.GetDirectoryName(path)  ' String
```

Returns the directory portion of `path` according to Chilkat path-parsing rules.

```
GetDirectoryName('C:\MyDir\MySubDir\myfile.ext')  ->  'C:\MyDir\MySubDir\'
GetDirectoryName('C:\MyDir\MySubDir')             ->  'C:\MyDir\'
GetDirectoryName('C:\')                             ->  'C:\'
```

Returns `Nothing` on failure

### FileAccess.GetExtension

`Chilkat 11.7.0 · asp · FileAccess · GetExtension · method · since 9.5.0.64`

```visual-basic
str = fileAccess.GetExtension(path)  ' String
```

Returns the filename extension portion of `path`, including the leading period. A period appearing only in a directory name is not treated as the file extension.

```
GetExtension('C:\mydir.old\myfile.ext')  ->  '.ext'
GetExtension('C:\mydir.old\')            ->  ''
```

Returns `Nothing` on failure

### FileAccess.GetFileName

`Chilkat 11.7.0 · asp · FileAccess · GetFileName · method · since 9.5.0.64`

```visual-basic
str = fileAccess.GetFileName(path)  ' String
```

Returns the final filename component of `path`, including its extension. If the path ends with a directory separator, the returned filename is empty.

```
GetFileName('C:\mydir\myfile.ext')  ->  'myfile.ext'
GetFileName('C:\mydir\')            ->  ''
```

Returns `Nothing` on failure

### FileAccess.GetFileNameWithoutExtension

`Chilkat 11.7.0 · asp · FileAccess · GetFileNameWithoutExtension · method · since 9.5.0.64`

```visual-basic
str = fileAccess.GetFileNameWithoutExtension(path)  ' String
```

Returns the final filename component of `path` with its extension removed. If `path` ends with a directory separator, the returned value is empty.

```
GetFileNameWithoutExtension('C:\mydir\myfile.ext')  ->  'myfile'
GetFileNameWithoutExtension('C:\mydir\')            ->  ''
```

Returns `Nothing` on failure

### FileAccess.GetFileTimeStr

`Chilkat 11.7.0 · asp · FileAccess · GetFileTimeStr · method · since 11.0.0`

```visual-basic
str = fileAccess.GetFileTimeStr(path, which)  ' String
```

Returns one file timestamp as an ISO 8601 UTC string in the form `YYYY-MM-DDTHH:MM:SSZ`. The `which` argument selects `0` = last-modified, `1` = last-access, or `2` = creation.

**Portability:** Creation/birth time is not available on every filesystem. The documented Chilkat behavior on Linux is to return the last-modified time when creation time is unavailable.

Returns `Nothing` on failure

### FileAccess.GetNumBlocks

`Chilkat 11.7.0 · asp · FileAccess · GetNumBlocks · method · since 9.5.0.58`

```visual-basic
n = fileAccess.GetNumBlocks(blockSize)  ' Long
```

Returns how many `blockSize`-byte blocks are required to cover the currently open file. A partial final block counts as one block. Returns `0` for an empty file and `-1` if no file is open.

**Calculation:** Conceptually this is `ceil(fileSize / blockSize)` for a non-empty file.

### FileAccess.GetTempFilename

`Chilkat 11.7.0 · asp · FileAccess · GetTempFilename · method`

```visual-basic
str = fileAccess.GetTempFilename(dirPath, prefix)  ' String
```

Generates a temporary pathname in `dirPath` using `prefix` and a random alphanumeric suffix, in the general form `prefix_xxxx.TMP`. The returned pathname is guaranteed not to already exist at the time it is generated.

Returns `Nothing` on failure

### FileAccess.OpenForAppend

`Chilkat 11.7.0 · asp · FileAccess · OpenForAppend · method`

```visual-basic
success = fileAccess.OpenForAppend(filePath)  ' Long (1/0)
```

Opens `filePath` for writing at end-of-file. The file is created if it does not exist. Existing content is preserved, and the initial file position is at the end.

**Open failures:** If the open/create operation fails, inspect `FileOpenError` and `FileOpenErrorMsg`. On Windows, `LockFileOnOpen` can request exclusive access for this method.

Returns 1 for success, 0 for failure.

### FileAccess.OpenForRead

`Chilkat 11.7.0 · asp · FileAccess · OpenForRead · method`

```visual-basic
success = fileAccess.OpenForRead(filePath)  ' Long (1/0)
```

Opens an existing `filePath` for reading. The file may contain text or binary data and must already exist.

**Open failures:** If the open/create operation fails, inspect `FileOpenError` and `FileOpenErrorMsg`. On Windows, `LockFileOnOpen` can request exclusive access for this method.

Returns 1 for success, 0 for failure.

### FileAccess.OpenForReadWrite

`Chilkat 11.7.0 · asp · FileAccess · OpenForReadWrite · method`

```visual-basic
success = fileAccess.OpenForReadWrite(filePath)  ' Long (1/0)
```

Opens `filePath` for both reading and writing. The file is created if necessary. Existing content is preserved, and the initial file position is at the beginning.

**Open failures:** If the open/create operation fails, inspect `FileOpenError` and `FileOpenErrorMsg`. On Windows, `LockFileOnOpen` can request exclusive access for this method.

Returns 1 for success, 0 for failure.

### FileAccess.OpenForWrite

`Chilkat 11.7.0 · asp · FileAccess · OpenForWrite · method`

```visual-basic
success = fileAccess.OpenForWrite(filePath)  ' Long (1/0)
```

Opens `filePath` for writing. The file is created if necessary; if it already exists, it is truncated to zero length when opened.

**Open failures:** If the open/create operation fails, inspect `FileOpenError` and `FileOpenErrorMsg`. On Windows, `LockFileOnOpen` can request exclusive access for this method.

Returns 1 for success, 0 for failure.

### FileAccess.ReadBinaryToEncoded

`Chilkat 11.7.0 · asp · FileAccess · ReadBinaryToEncoded · method`

```visual-basic
str = fileAccess.ReadBinaryToEncoded(filePath, encoding)  ' String
```

Reads the entire file at `filePath` as binary data and returns an encoded textual representation. Supported encoding names documented for this method include `base64`, `hex`, `qp`, and `url`.

**Encoding is not encryption:** These encodings transform bytes into text; they do not provide confidentiality.

Returns `Nothing` on failure

### FileAccess.ReadBlock

`Chilkat 11.7.0 · asp · FileAccess · ReadBlock · method · since 9.5.0.58`

```visual-basic
bytes = fileAccess.ReadBlock(blockIndex, blockSize)  ' Variant
```

Reads the zero-based block `blockIndex` from the currently open file, where each block is `blockSize` bytes. If the final block is shorter than `blockSize`, only the remaining bytes are returned.

Returns a zero-length byte array (as a Variant) on failure.  
An empty array will have a UBound of -1 meaning 0 elements.

### FileAccess.ReadBlockBd

`Chilkat 11.7.0 · asp · FileAccess · ReadBlockBd · method · since 9.5.0.79`

```visual-basic
success = fileAccess.ReadBlockBd(blockIndex, blockSize, bd)  ' Long (1/0)
```

Reads the zero-based block `blockIndex` from the currently open file, using `blockSize` bytes per block, and appends the bytes to `bd`. A partial final block is appended at its actual length.

**Destination behavior:** Existing contents of `bd` are preserved; the block bytes are appended.

Returns 1 for success, 0 for failure.

### FileAccess.ReadEntireFile

`Chilkat 11.7.0 · asp · FileAccess · ReadEntireFile · method`

```visual-basic
bytes = fileAccess.ReadEntireFile(filePath)  ' Variant
```

Reads the entire file at `filePath` as raw bytes and returns the binary data.

**Memory use:** The whole file is loaded into memory. For very large files, use `OpenForRead` together with `FileReadBd` or block-oriented methods.

Returns a zero-length byte array (as a Variant) on failure.  
An empty array will have a UBound of -1 meaning 0 elements.

### FileAccess.ReadEntireTextFile

`Chilkat 11.7.0 · asp · FileAccess · ReadEntireTextFile · method`

```visual-basic
str = fileAccess.ReadEntireTextFile(filePath, charset)  ' String
```

Reads the entire file at `filePath`, decodes its bytes using `charset`, and returns the resulting text.

**Charset matters:** The charset controls byte-to-character conversion. Use the encoding that actually represents the file; incorrect charset selection can produce incorrect text or conversion failure.

Returns `Nothing` on failure

### FileAccess.ReadNextFragment

`Chilkat 11.7.0 · asp · FileAccess · ReadNextFragment · method · since 9.5.0.80`

```visual-basic
n = fileAccess.ReadNextFragment(startAtBeginning, beginMarker, endMarker, charset, sb)  ' Long
```

Scans the currently open file for the next text fragment beginning with `beginMarker` and ending with `endMarker`. The matched fragment, including both markers, is decoded using `charset` and appended to `sb`. If `startAtBeginning` is `1`, scanning restarts at the beginning of the file; otherwise it continues after the previously matched fragment.

|  |  |
| --- | --- |
| `1` | A fragment was found and appended. |
| `0` | No matching fragment was found. |
| `-1` | An error occurred while reading. |

### FileAccess.ReassembleFile

`Chilkat 11.7.0 · asp · FileAccess · ReassembleFile · method`

```visual-basic
success = fileAccess.ReassembleFile(partsDirPath, partPrefix, partExtension, reassembledFilename)  ' Long (1/0)
```

Reassembles a file previously divided by `SplitFile`. Parts are read from `partsDirPath` using the supplied `partPrefix` and `partExtension`, and the combined bytes are written to `reassembledFilename`.

**Byte-for-byte reconstruction:** Reassembly is a binary operation; no text decoding or newline conversion is performed.

Returns 1 for success, 0 for failure.

### FileAccess.ReplaceStrings

`Chilkat 11.7.0 · asp · FileAccess · ReplaceStrings · method`

```visual-basic
n = fileAccess.ReplaceStrings(filePath, charset, existingString, replacementString)  ' Long
```

Reads the file at `filePath` as text using `charset`, replaces occurrences of `existingString` with `replacementString`, writes the updated text back to the file, and returns the number of replacements made.

**Text operation:** This is character-based replacement after decoding the file. It is not suitable for arbitrary binary files.

### FileAccess.SetCurrentDir

`Chilkat 11.7.0 · asp · FileAccess · SetCurrentDir · method`

```visual-basic
success = fileAccess.SetCurrentDir(dirPath)  ' Long (1/0)
```

Changes the current working directory of the calling process to `dirPath`.

**Process-wide effect:** The current directory is normally process-wide, so changing it can affect relative paths used by other code or threads. Absolute paths avoid that dependency.

Returns 1 for success, 0 for failure.

### FileAccess.SetFileTimes

`Chilkat 11.7.0 · asp · FileAccess · SetFileTimes · method`

```visual-basic
success = fileAccess.SetFileTimes(filePath, createTime, lastAccessTime, lastModTime)  ' Long (1/0)
```

Sets the creation, last-access, and last-modified timestamps for `filePath` from the supplied `CkDateTime` objects. On filesystems that do not support a creation/birth time, `createTime` is ignored.

**Filesystem differences:** Timestamp availability and precision are filesystem- and operating-system-dependent.

Returns 1 for success, 0 for failure.

### FileAccess.SetLastModified

`Chilkat 11.7.0 · asp · FileAccess · SetLastModified · method`

```visual-basic
success = fileAccess.SetLastModified(filePath, lastModified)  ' Long (1/0)
```

Sets the last-modified timestamp of `filePath` from `lastModified`. The precision actually stored depends on the underlying filesystem.

Returns 1 for success, 0 for failure.

### FileAccess.SplitFile

`Chilkat 11.7.0 · asp · FileAccess · SplitFile · method`

```visual-basic
success = fileAccess.SplitFile(fileToSplit, partPrefix, partExtension, partSize, destDir)  ' Long (1/0)
```

Splits `fileToSplit` into sequential binary parts of up to `partSize` bytes and writes them to `destDir` using `partPrefix` and `partExtension`. Use `ReassembleFile` to reconstruct the original file.

Returns 1 for success, 0 for failure.

### FileAccess.SymlinkCreate

`Chilkat 11.7.0 · asp · FileAccess · SymlinkCreate · method · since 9.5.0.77`

```visual-basic
success = fileAccess.SymlinkCreate(targetPath, linkPath)  ' Long (1/0)
```

Creates a symbolic link at `linkPath` that refers to `targetPath`.

**Windows note:** A Windows symbolic link is not the same as a Windows shortcut. Windows may require elevated privileges or an operating-system configuration such as Developer Mode that permits unprivileged symbolic-link creation, depending on system policy and how the application is launched.

Returns 1 for success, 0 for failure.

### FileAccess.SymlinkTarget

`Chilkat 11.7.0 · asp · FileAccess · SymlinkTarget · method · since 9.5.0.77`

```visual-basic
str = fileAccess.SymlinkTarget(linkPath)  ' String
```

Returns the resolved target pathname for the symbolic link at `linkPath`. On Windows, this method also understands Windows shortcut (`.lnk`) files and returns the absolute target path.

**Link vs. target:** A symbolic link is a filesystem object that refers to another path. A Windows shortcut is a separate shell-file format; Chilkat supports both here even though they are different mechanisms.

Returns `Nothing` on failure

### FileAccess.TreeDelete

`Chilkat 11.7.0 · asp · FileAccess · TreeDelete · method`

```visual-basic
success = fileAccess.TreeDelete(path)  ' Long (1/0)
```

Recursively deletes the directory tree rooted at `path`, including contained files and subdirectories.

**Destructive operation:** This operation is recursive and destructive. Ensure `path` identifies the intended tree before calling it.

Returns 1 for success, 0 for failure.

### FileAccess.Truncate

`Chilkat 11.7.0 · asp · FileAccess · Truncate · method · since 9.5.0.80`

```visual-basic
success = fileAccess.Truncate()  ' Long (1/0)
```

Truncates the currently open file at the current file position. Bytes at and after that position are removed, making the current position the new end-of-file.

**Use with FileSeek:** A common pattern is to seek to the desired new length and then call `Truncate`.

Returns 1 for success, 0 for failure.

### FileAccess.WriteEntireFile

`Chilkat 11.7.0 · asp · FileAccess · WriteEntireFile · method`

```visual-basic
success = fileAccess.WriteEntireFile(filePath, fileData)  ' Long (1/0)
```

Creates or opens `filePath`, writes all bytes from `fileData`, and closes the file. Existing file content is replaced.

Returns 1 for success, 0 for failure.

### FileAccess.WriteEntireTextFile

`Chilkat 11.7.0 · asp · FileAccess · WriteEntireTextFile · method`

```visual-basic
success = fileAccess.WriteEntireTextFile(filePath, textData, charset, includedPreamble)  ' Long (1/0)
```

Creates or opens `filePath`, encodes `textData` using `charset`, writes the resulting bytes, and closes the file. Existing file content is replaced. If `includePreamble` is `1`, an appropriate preamble/BOM is included for encodings such as UTF-8 or UTF-16.

**BOM terminology:** A BOM is part of the byte representation of the text file; it is not part of the application string itself.

Returns 1 for success, 0 for failure.

## Deprecated members — do not use in new code

| Member | Kind | Deprecated in | Use instead |
|---|---|---|---|
| `GetFileTime` | method | before 11.6.1 | `GetFileTimeStr` |
| `GetLastModified` | method | before 11.6.1 | `GetFileTimeStr` |

## Related classes

[`BinData`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/asp/classes/BinData.md), [`CkDateTime`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/asp/classes/CkDateTime.md), [`StringBuilder`](https://www.chilkatsoft.com/ai-docs/v/11.7.0/asp/classes/StringBuilder.md)

