比如给定"c:\ddd\ddd\ddd"就是有效的,给定"c:\ddd\*d*/"就是无效的,不管硬盘上是否存在该文件或者文件夹.
不知道VC里面有没有现成的函数调用?谢谢!!!!
不知道VC里面有没有现成的函数调用?谢谢!!!!
解决方案 »
- recvfrom问题
- 当客户从银行汇款到我的卡上时,登陆到银行网上查看时只发现我卡上的金额增长了,没有汇款客户的信息,尤其是在较短的时间内有几个客户时更难区别这些客户,现在考虑有两种办法,但都不太理想,请大家看看还有什么办法。我考虑的两种办法如下:
- 求助:外文输入显示时出现问题
- LoadIcon的问
- HOOK API中如何返回原来函数的地址?
- 为何从串口中读不出数据,明明写入成功了?
- 用ATL COM AppWizard自动生成的组件没有接口
- VC画图
- 怎样从SafeArray里面抽出指定的值
- 请教一个关于串口通讯的问题
- 请问大家,我已知一个位图句柄或一个DC句柄,如何将它回写到一个位图文件中呢?就是把显示的内容保存在位图文件中。
- 请教大家一个简单的问题:我在连续的发送几个数据包后,之后马上出现了发送数据的阻塞的情况,具体如下,谢谢,急呀
LPCTSTR lpPathName // new directory name
);BOOL CreateDirectory(
LPCTSTR lpPathName, // directory name
LPSECURITY_ATTRIBUTES lpSecurityAttributes // SD
);
1、
CFileFind f;
if(f.FindFile("c:\\temp"))
AfxMessageBox("存在");
//Directory exist.
else
AfxMessageBox("不存在");
//Not exist.2、
if(_access("c:\\temp", 0) == 0){
AfxMessageBox("存在");
}
else{
AfxMessageBox("不存在");
}
所以用pathisdirectory就找不到该文件,所以你创建这种文件名的文件就会创建失败
LPCTSTR lpPathName // new directory name
);BOOL CreateDirectory(
LPCTSTR lpPathName, // directory name
LPSECURITY_ATTRIBUTES lpSecurityAttributes // SD
);
#include <shellapi.h>
#include <io.h>
#include <sys/stat.h>
#include <direct.h>#include "Category.h"
#include "HttpCar.h"BOOL File::create(LPCTSTR p, __int64 s)
{
BOOL ret = FALSE;
// ULONG h = (s & 0xffffffff00000000) >> 32;
// ULONG l = (s & 0xffffffff); this->path = p; if (-1 == (ret = _taccess(p, 0))) {
if (FALSE == mkDir(p)) {
return FALSE;
} INT hFile = _tcreat(p, _S_IREAD | _S_IWRITE);
if (hFile != -1) {
if (0 == _chsize(hFile, s)) {
_close(hFile);
return ret = TRUE;
} else {
_close(hFile);
return ret;
}
} // below method use memory mapping file creae "large" files
// HANDLE hsrcfile = CreateFile(p,
// GENERIC_READ | GENERIC_WRITE ,
// FILE_SHARE_READ | FILE_SHARE_WRITE,
// NULL,
// CREATE_NEW,
// FILE_ATTRIBUTE_NORMAL,
// NULL);
// ASSERT(hsrcfile != NULL);
//
// HANDLE hmap = CreateFileMapping(hsrcfile,
// NULL,
// PAGE_READWRITE,
// h, l, NULL);
// ASSERT(hmap);
//
// LPVOID pfile = MapViewOfFile(hmap,
// FILE_MAP_ALL_ACCESS,
// 0, 0, 0);
// ASSERT(pfile != NULL);
//
// ULONG writed;
// ret = WriteFile(hsrcfile, pfile, s, &writed, NULL);
// ASSERT(ret);
//
// UnmapViewOfFile(pfile);
// CloseHandle(hmap);
// CloseHandle(hsrcfile);
ret = TRUE;
} else if (ret == 0) {
ret = TRUE;
}
return ret;
}ULONG File::write(LPCTSTR content, ULONG contentsize, CarInfo *ci)
{
ASSERT(ci != NULL);
ULONG ret = 0L; FILE *fp = fopen(path, "r+b");
if (fp)
{
fseek(fp, ci->cur, SEEK_SET);
fwrite((LPVOID)(content), sizeof(TCHAR),
contentsize, fp);
fclose(fp);
ci->cur += contentsize;
return contentsize;
}
else
{
return 0L;
}}BOOL File::mkDir(LPCTSTR path)
{
BOOL ret = FALSE;
using std::string; string s(path);
string dir;
string::size_type pos, pos_pre = 0;
pos = pos_pre; // check if dir exist
char *p = strrchr(s.c_str(), '\\');
dir = s.substr(0, p - s.c_str() + 1); if (0 == access(dir.c_str(), 0)) {
return TRUE;
}
pos = s.find_first_of('\\');
while (pos != string::npos) {
dir = s.substr(0, pos + 1); ++pos;
if (access(dir.c_str(), 0) == -1) {
// make dir
if (_mkdir(dir.c_str()) != 0) {
return FALSE;
}
}
pos = s.find('\\', pos);
} // while return TRUE;
}