logo
VitNX3 Documentation

# File.WriteTextAsUTF8_ToTemp Method

Namespace: VitNX3.Functions.FileSystem
Assembly: VitNX3 (in VitNX3.dll)
Writes the text to file as UTF-8 to temp folder.
VB
C#
F#
C++
JScript
Copy

    public static string[] WriteTextAsUTF8_ToTemp(
       string text,
       string targetFile
    )

    This language is not supported or no code example is available.

#### Parameters

text
  string

The text.

targetFile
  string

The target file.

#### Return Value

string[]

An array of string (File name and File path).

Source code
VB
C#
F#
C++
JScript
Copy

    public static string[] WriteTextAsUTF8_ToTemp(string text,
         string targetFile)
     {
         string fileName = NameGenerator(targetFile, "txt");
         string filePath = $@"{Path.GetTempPath()}\{fileName}";
         using (FileStream fs = System.IO.File.OpenWrite(filePath))
         {
             var data = text;
             byte[] bytes = Encoding.UTF8.GetBytes(data);
             fs.Write(bytes, 0, bytes.Length);
         }
         return new string[] { fileName, filePath };
     }

    This language is not supported or no code example is available.

Applies to

#### .NET Framework

Supported in: 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8

#### .NET Core

Supported in: 5.0+, 6.0+
See Also
File Class
VitNX3.Functions.FileSystem Namespace