如何在批处理中获取文件夹中的文件?
How to get file in folder in batch process?
我必须在文件夹中获取文件。我的过程可以在 Batch.
中工作
我的代码是这样的:
Io file;
FileIoPermission perm;
int handle;
Filename fileName;
[handle, filename] = WINAPI::findFirstFile( myFilePatch + "\*.txt");
fileOpen = strFmt (myFilePatch + "\" + filename);
if (filename)
{
perm = new FileIoPermission(filename, 'r');
perm.assert();
file = new TextIo(filename, 'r', 65001);
}
//etc... other code
// I go on to find another file
filename = WinAPI::findNextFile(handle);
fileOpen = strFmt (myFilePatch + "\" + filename);
if (filename)
{
// open file....
}
我的问题是 WinAPI.findFirstFile
和 WinAPI::findNextFile
我有一个错误。
如何在文件夹中以批处理方式搜索文件?
谢谢大家,
尽情享受吧!
使用 System.IO.DirectoryInfo 并使用 for-loop 遍历文件。只需将下面的文件夹路径替换为您文件夹的位置,它就会生成文件夹内所有文件的列表。
static void loopDirectory(Args _args)
{
System.IO.DirectoryInfo directory;
System.IO.FileInfo[] files;
System.IO.FileInfo file;
InteropPermission permission;
Filename tmpFilePath;
Filename tmpFileNameShort;
Filename tmpFileExt;
str fileNameTemp;
counter filesCount;
counter loop;
permission = new InteropPermission(InteropKind::ClrInterop);
permission.assert();
directory = new System.IO.DirectoryInfo(@"C:\Users...");
files = directory.GetFiles();
filesCount = files.get_Length();
for (loop = 0; loop < filesCount; loop++)
{
file = files.GetValue(loop);
fileNameTemp = file.get_FullName();
[tmpFilePath, tmpFileNameShort, tmpFileExt] = fileNameSplit(fileNameTemp);
info(tmpFileNameShort);
}
CodeAccessPermission::revertAssert();
}
我必须在文件夹中获取文件。我的过程可以在 Batch.
中工作我的代码是这样的:
Io file;
FileIoPermission perm;
int handle;
Filename fileName;
[handle, filename] = WINAPI::findFirstFile( myFilePatch + "\*.txt");
fileOpen = strFmt (myFilePatch + "\" + filename);
if (filename)
{
perm = new FileIoPermission(filename, 'r');
perm.assert();
file = new TextIo(filename, 'r', 65001);
}
//etc... other code
// I go on to find another file
filename = WinAPI::findNextFile(handle);
fileOpen = strFmt (myFilePatch + "\" + filename);
if (filename)
{
// open file....
}
我的问题是 WinAPI.findFirstFile
和 WinAPI::findNextFile
我有一个错误。
如何在文件夹中以批处理方式搜索文件?
谢谢大家,
尽情享受吧!
使用 System.IO.DirectoryInfo 并使用 for-loop 遍历文件。只需将下面的文件夹路径替换为您文件夹的位置,它就会生成文件夹内所有文件的列表。
static void loopDirectory(Args _args)
{
System.IO.DirectoryInfo directory;
System.IO.FileInfo[] files;
System.IO.FileInfo file;
InteropPermission permission;
Filename tmpFilePath;
Filename tmpFileNameShort;
Filename tmpFileExt;
str fileNameTemp;
counter filesCount;
counter loop;
permission = new InteropPermission(InteropKind::ClrInterop);
permission.assert();
directory = new System.IO.DirectoryInfo(@"C:\Users...");
files = directory.GetFiles();
filesCount = files.get_Length();
for (loop = 0; loop < filesCount; loop++)
{
file = files.GetValue(loop);
fileNameTemp = file.get_FullName();
[tmpFilePath, tmpFileNameShort, tmpFileExt] = fileNameSplit(fileNameTemp);
info(tmpFileNameShort);
}
CodeAccessPermission::revertAssert();
}