local Folder = (_SourceFolder);
if(File.Find(Folder, "*.dllg", false, false, nil, nil))then
Dialog.Message("", "it was found");
else
Dialog.Message("", "it was not found");
end
documents = File.Find(folder, "*.doc", true, true, nil, nil)
if (documents~=nil) then
--found files
print("Archivos encontrados: "..#documentos)
for file,key in ipairs(documenmtos) do
print("Archivo: "..file)
end
else
--no files found
end
El valor que retorna la función es una tabla que contiene todas las rutas de archivos que coincidieron con los argumentos establecidos, si no se encontró ninguna coincidencia devuelve nil.Return
(table) A table containing the paths to all of the files that were found. If no files were found or an error occurs, nil is returned. You can use Application.GetLastError to determine whether this action failed, and why.
Note: If IncludeFolders is true, the result will always include the folders that were encountered during the search.
documents = File.Find(folder, "*.doc", true, true, nil, nil) -- Se ejecuta la función
-- Con una sentencia if
if (documents~=nil) then -- El valor retornado es una tabla o nil en caso de no haber encontrado coincidencias, aquí nos aseguramos de que el valor devuelto no sea nil
print("Archivos encontrados: "..#documents)
for _, path in ipairs(documents ) do -- Con un bucle for obtenemos los valores de los índices de la tabla
print("Archivo: "..path) -- path es el valor de un indice de la tabla, recordando que cada indice contiene la ruta de los archivos coincidentes.
end
else
--no files found
end
folder = Input.GetText("Input1")
documents = File.Find(folder, "*.doc", true, true, nil, nil)
if (documents~=nil) then
print("Archivos encontrados: "..#documents)
Label.SetText("Label1", documents .. "este es el documento que se encontró en esta dirección")
for _, path in ipairs(documents ) do
print("Archivo: "..path)
end
else
Label.SetText("Label1", "Lo siento no hay archivo")
end
folder = Label.GetText("LabelFOLDER")
local document = File.Find(folder, "*.doc", true, true, nil, nil)[1]
Label.SetText("Label1", documents .. "este es el documento que se encontró en esta dirección")
else
Label.SetText("Label1", "Lo siento no hay archivo")
end
local _Folder = Input.GetText("Folder")
local _FileName = Input.GetText("FileName")
local _FileFind = File.Find(_Folder, _FileName, false, false, nil, nil)
if _FileFind ~= nil then
-- Se encontró el archivo
else
-- No se encontró el archivo
end
local _direccion = Input.GetText("Input1")
local file = File.Find(_direccion, "\\" .. "*.txt", true, true, nil, nil)[1]
if file ~= nil then
Label.SetText("Label1", file);
else
Label.SetText("Label1", "no");
end
local _Folder = Input.GetText("Input1")
local _File = File.Find(_Folder, "*.txt")
Debug.ShowWindow()
local _Return = type(_File)
Debug.Print("La función File.Find ha devuelto un valor del tipo \"".._Return.."\"\r\n")
if _File ~= nil then
-- Se han encontrado coinsidencias con .txt
Debug.Print("Se han logrado conseguir "..#_File.." coincidencias con .txt\r\nLas coincidencias son:\r\n")
local Arg3 = _File -- _File es la variable contenedora de la tabla devuelta por File.Find
for Arg1, Arg2 in pairs (_File) do -- Bucle for con tres argumentos para tablas; Argumento 1: Índice de la tabla; Arguento 2: Contenido del índice; Arguento 3: Tabla
Debug.Print("\t"..Arg2.."\r\n")
end
else
Debug.Print("Se ha producido un error en la búsqueda, no se han encontrado coincidencias.")
end