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.

 

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.

 

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");

 

Category

Load and Save


[idh_iwpmemo_loadfromfile.htm]    Copyright © 2007 by WPCubed GmbH