LoadFromFile Method

[Top]  [Chapter]  [Previous]  [Next]

Declaration

bool LoadFromFile([In] string filename, [In] bool Insert, [In] string FormatStr);

Description

Load a file into this editor.

 

Supported formats are ANSI, UNICODE, WPTOOLS, HTML and RTF. You can select the format using the "FormatStr" parameter.

RTF2PDF/TextDynamic Server V4.23 and later can also load and save MS Word DocX files. TextDynamic 7 can load and save in this format if the DocX license had been activated.

 

 

Parameters

filename

The name of the file

Insert

true to insert the file at the cursor position, otherwise the complete text is replaced.

FormatStr

Select the reader and set options. It is also possible to just the contents of a merge field using the syntax f:name=

 

This VB.NET example code display a file open dialog and loads the selected file into the editor.

 

  Dim OpenFileDialog As New OpenFileDialog

   OpenFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments

   OpenFileDialog.Filter = "Textfiles (*.rtf,*.wpt,*.htm,*.html)|*.rtf;*.wpt;*.htm;*.html|All Files (*.*)|*.*"

  If (OpenFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then

          Dim FileName As String = OpenFileDialog.FileName

          Dim memo As WPDynamic.IWPMemo

           memo = WpdllInt1.Memo

          If (memo Is Nothing) Or _

              Not memo.LoadFromFile(FileName, False, "AUTO") Then

               MessageBox.Show("Cannot load " + FileName)

          End If

  End If

Tip: In ASP projects you can use Server.MapPath(".") to get the current directory.

 

   if (!wpdllint1.Memo.LoadFromFile(Server.MapPath(".") + "test.rtf",true,""))

      wpdllint1.TextCursor.InputText("Cannot open file TEST.RTF");

 

 

Tip: In case the addon wphttpget.dll was activated using Memo.TextCommandStr(6,1, dll_path )

LoadFromFile can be also used with a http path to load data from a web server.

Category

Load and Save


[idh_iwpmemo_loadfromfile.htm]    Copyright © 2007 by WPCubed GmbH