StringExtensionsToFileId Method

Converts a file name or path string into a standardized file identifier.

Definition

Namespace: GenerativeAI
Assembly: GenerativeAI (in GenerativeAI.dll) Version: 2.0.2+aa51399cad6d90cc71158d589a6268608b3c1893
C#
public static string ToFileId(
	this string fileName
)

Parameters

fileName  String
The input file name or path. If the string contains a forward slash ('/'), it must start with "files/" (case-insensitive). Otherwise, the method will prefix the provided name with "files/".

Return Value

String
A string formatted as a valid file identifier. If the input string already starts with "files/" and contains a '/', it will be returned in lowercase.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type String. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Exceptions

ArgumentException Thrown if the input string contains a '/' but does not start with "files/".

See Also