FileInfo.Name (Propiedad)
Ensamblado: mscorlib (en mscorlib.dll)
En la siguiente tabla se muestran ejemplos de otras tareas de E/S típicas o relacionadas.
| Para realizar esta operación... | Vea el ejemplo de este tema... |
|---|---|
| Crear un archivo de texto | |
| Escribir en un archivo de texto. | |
| Leer de un archivo de texto. | |
| Anexar texto a un archivo. | |
| Recuperar una extensión de archivo | |
| Recuperar la ruta de acceso completa de un archivo | |
| Recuperar el nombre de archivo y la extensión de una ruta de acceso | |
| Cambiar la extensión de un archivo | |
| Recuperar sólo el nombre de directorio de una ruta de acceso |
En el siguiente ejemplo se utiliza la propiedad Name para mostrar los nombres de los archivos del directorio actual.
using System; using System.IO; public class NameTest { public static void Main() { // Create a reference to the current directory. DirectoryInfo di = new DirectoryInfo(Environment.CurrentDirectory); // Create an array representing the files in the current directory. FileInfo[] fi = di.GetFiles(); Console.WriteLine("The following files exist in the current directory:"); // Print out the names of the files in the current directory. foreach (FileInfo fiTemp in fi) Console.WriteLine(fiTemp.Name); } }
import System.*;
import System.IO.*;
public class NameTest
{
public static void main(String[] args)
{
// Create a reference to the current directory.
DirectoryInfo di = new DirectoryInfo(Environment.
get_CurrentDirectory());
// Create an array representing the files in the current directory.
FileInfo fi[] = di.GetFiles();
Console.WriteLine("The following files exist in the "
+ " current directory:");
// Print out the names of the files in the current directory.
for (int iCtr = 0; iCtr < fi.length; iCtr++) {
FileInfo fiTemp = fi[iCtr];
Console.WriteLine(fiTemp.get_Name());
}
} //main
} //NameTest
import System; import System.IO; public class NameTest { public static function Main() : void { // Create a reference to the current directory. var di : DirectoryInfo = new DirectoryInfo(Environment.CurrentDirectory); // Create an array representing the files in the current directory. var fi : FileInfo[] = di.GetFiles(); Console.WriteLine("The following files exist in the current directory:"); // Print out the names of the files in the current directory. for (var i : int in fi) Console.WriteLine(fi[i]); } } NameTest.Main();
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter Edition
.NET Framework no admite todas las versiones de cada plataforma. Para obtener una lista de las versiones admitidas, vea Requisitos del sistema.