6 个解决方案
#1
#include <stdio.h>
#include <stdlib.h>
char cmdstr[1024];
char d;
char fn[256];
int main() {
printf("Enter a filename:");fflush(stdout);
scanf("%[^\n]",fn);
sprintf(cmdstr,"dir /b /a-d /s \"%c:\\%s\" >d:\\filesinall.txt",'c',fn);
system(cmdstr);
for (d='d';d<='z';d++) {
sprintf(cmdstr,"dir /b /a-d /s \"%c:\\%s\" >>d:\\filesinall.txt",d,fn);
system(cmdstr);
}
system("type d:\\filesinall.txt");
return 0;
}
#2
大神留个联系方式呀,能不能帮我解决个小问题,有酬谢
#3
你这个不好用啊
#4
可以吗?得是当前路径下的吧?不同文件夹下的文件可以同名的呀
#5
GetFullPathName function
Retrieves the full path and file name of the specified file.
DWORD WINAPI GetFullPathName(
_In_ LPCTSTR lpFileName,
_In_ DWORD nBufferLength,
_Out_ LPTSTR lpBuffer,
_Out_ LPTSTR *lpFilePart
);
Parameters
lpFileName [in]
The name of the file.
This parameter can be a short (the 8.3 form) or long file name. This string can also be a share or volume name.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.
nBufferLength [in]
The size of the buffer to receive the null-terminated string for the drive and path, in TCHARs.
lpBuffer [out]
A pointer to a buffer that receives the null-terminated string for the drive and path.
lpFilePart [out]
A pointer to a buffer that receives the address (within lpBuffer) of the final file name component in the path.
This parameter can be NULL.
If lpBuffer refers to a directory and not a file, lpFilePart receives zero.
Retrieves the full path and file name of the specified file.
DWORD WINAPI GetFullPathName(
_In_ LPCTSTR lpFileName,
_In_ DWORD nBufferLength,
_Out_ LPTSTR lpBuffer,
_Out_ LPTSTR *lpFilePart
);
Parameters
lpFileName [in]
The name of the file.
This parameter can be a short (the 8.3 form) or long file name. This string can also be a share or volume name.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.
nBufferLength [in]
The size of the buffer to receive the null-terminated string for the drive and path, in TCHARs.
lpBuffer [out]
A pointer to a buffer that receives the null-terminated string for the drive and path.
lpFilePart [out]
A pointer to a buffer that receives the address (within lpBuffer) of the final file name component in the path.
This parameter can be NULL.
If lpBuffer refers to a directory and not a file, lpFilePart receives zero.
#6
WCHAR buffer[BUFSIZ] = {0};
LPWSTR lpPart[BUFSIZ]={0};
// Retrieve a full path name for a file. The file does not need to
// exist.
GetFullPathName(_T("Big5.dat"),
BUFSIZ,
buffer,
lpPart);
#1
#include <stdio.h>
#include <stdlib.h>
char cmdstr[1024];
char d;
char fn[256];
int main() {
printf("Enter a filename:");fflush(stdout);
scanf("%[^\n]",fn);
sprintf(cmdstr,"dir /b /a-d /s \"%c:\\%s\" >d:\\filesinall.txt",'c',fn);
system(cmdstr);
for (d='d';d<='z';d++) {
sprintf(cmdstr,"dir /b /a-d /s \"%c:\\%s\" >>d:\\filesinall.txt",d,fn);
system(cmdstr);
}
system("type d:\\filesinall.txt");
return 0;
}
#2
大神留个联系方式呀,能不能帮我解决个小问题,有酬谢
#3
你这个不好用啊
#4
可以吗?得是当前路径下的吧?不同文件夹下的文件可以同名的呀
#5
GetFullPathName function
Retrieves the full path and file name of the specified file.
DWORD WINAPI GetFullPathName(
_In_ LPCTSTR lpFileName,
_In_ DWORD nBufferLength,
_Out_ LPTSTR lpBuffer,
_Out_ LPTSTR *lpFilePart
);
Parameters
lpFileName [in]
The name of the file.
This parameter can be a short (the 8.3 form) or long file name. This string can also be a share or volume name.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.
nBufferLength [in]
The size of the buffer to receive the null-terminated string for the drive and path, in TCHARs.
lpBuffer [out]
A pointer to a buffer that receives the null-terminated string for the drive and path.
lpFilePart [out]
A pointer to a buffer that receives the address (within lpBuffer) of the final file name component in the path.
This parameter can be NULL.
If lpBuffer refers to a directory and not a file, lpFilePart receives zero.
Retrieves the full path and file name of the specified file.
DWORD WINAPI GetFullPathName(
_In_ LPCTSTR lpFileName,
_In_ DWORD nBufferLength,
_Out_ LPTSTR lpBuffer,
_Out_ LPTSTR *lpFilePart
);
Parameters
lpFileName [in]
The name of the file.
This parameter can be a short (the 8.3 form) or long file name. This string can also be a share or volume name.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.
nBufferLength [in]
The size of the buffer to receive the null-terminated string for the drive and path, in TCHARs.
lpBuffer [out]
A pointer to a buffer that receives the null-terminated string for the drive and path.
lpFilePart [out]
A pointer to a buffer that receives the address (within lpBuffer) of the final file name component in the path.
This parameter can be NULL.
If lpBuffer refers to a directory and not a file, lpFilePart receives zero.
#6
WCHAR buffer[BUFSIZ] = {0};
LPWSTR lpPart[BUFSIZ]={0};
// Retrieve a full path name for a file. The file does not need to
// exist.
GetFullPathName(_T("Big5.dat"),
BUFSIZ,
buffer,
lpPart);