Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

VB.NET Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(VB.NET) Using a .NET System.IO.Stream with Chilkat

Important: The Chilkat.StreamConnector class is not available in .NET Core or Mono. It is available only in the traditional Chilkat .NET assemblies.

The Chilkat.StreamConnector is a utility class to connect a System.IO.Stream to a Chilkat.Stream. Once connected, a .NET application can read or write a System.IO.Stream.

Here we have a trivial example showing how to connect a System.IO.Stream to a Chilkat.Stream.

Chilkat .NET Downloads

Chilkat .NET Framework

Chilkat for .NET Core

' First we'll demonstrate how to use a System.IO.FileStream as a source.
' Note: Any type of System.IO.Stream could be used, not just FileStream.

Dim srcPath As String = "qa_data/hamlet.xml"

Dim fs as System.IO.FileStream 
fs = File.OpenRead(srcPath)


Dim sc As New Chilkat.StreamConnector
Dim stream As New Chilkat.Stream

' Set the System.IO.FileStream as the source for the Chilkat.Stream.
' When the Chilkat.Stream needs input, it will read from the System.IO.FileStream
Dim success As Boolean = sc.SetAsSource(fs,stream)

' Set the stream's output (sink) to a file.
Dim outPath As String = "qa_output/hamlet_copy_2.xml"
stream.SinkFile = outPath

' Run the stream to copy from source to sink.
success = stream.RunStream()
If (success <> True) Then
    Debug.WriteLine(stream.LastErrorText)
    Exit Sub
End If


Debug.WriteLine("File successfully streamed from a System.IO.Stream.")

' ----------------------------------------------------
' Now let's output to a System.IO.Stream

' Call Reset to make sure the Chilkat.Stream object has closed everything
' and is ready for something new..
stream.Reset()

' Clear the SinkFile property.  We'll be writing to a System.IO.Stream instead..
stream.SinkFile = ""

' Open a file for writing:
Dim path3 As String = "qa_output/hamlet_copy_3.xml"

Dim fsOut As System.IO.FileStream
fsOut = File.OpenWrite(path3)

stream.SourceFile = srcPath

' Set the fsOut to be the sink of the Chilkat.Stream
success = sc.SetAsSink(fsOut,stream)

' Run the stream.
' The file is copied from the source to the sink...
success = stream.RunStream()

' Make sure we close our System.IO.Stream

fsOut.Close()

If (success <> True) Then
    Debug.WriteLine(stream.LastErrorText)
    Exit Sub
End If

Debug.WriteLine("File successfully streamed to a System.IO.Stream.")

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.