コメント |
@DIV
using System;
using System.Text;
using System.Runtime.InteropServices;
public class App
{
[DllImport( "Kernel32.dll", CharSet=CharSet.Auto )]
public static extern int FindFirstFile(
String fileName,
[ In, Out ] FindData findFileData
);
[DllImport( "Kernel32.dll", CharSet=CharSet.Auto )]
public static extern int FindNextFile(
int hFindFile,
[ In, Out ] FindData findFileData
);
public static void Main() {
FindData wfd = new FindData();
int handle = FindFirstFile( "C:\\tmp\\*.*", wfd );
int ret = -1;
while( handle != -1 && ret != 0 ) {
Console.WriteLine( "{1,-10} {0}", wfd.fileName, wfd.nFileSizeLow );
ret = FindNextFile( handle, wfd );
}
}
}
[ StructLayout( LayoutKind.Sequential, CharSet=CharSet.Auto )]
public class FindData
{
public int fileAttributes = 0;
public int creationTime_lowDateTime = 0 ;
public int creationTime_highDateTime = 0;
public int lastAccessTime_lowDateTime = 0;
public int lastAccessTime_highDateTime = 0;
public int lastWriteTime_lowDateTime = 0;
public int lastWriteTime_highDateTime = 0;
public int nFileSizeHigh = 0;
public int nFileSizeLow = 0;
public int dwReserved0 = 0;
public int dwReserved1 = 0;
[ MarshalAs( UnmanagedType.ByValTStr, SizeConst=256 )]
public String fileName = null;
[ MarshalAs( UnmanagedType.ByValTStr, SizeConst=14 )]
public String alternateFileName = null;
}
@END
|