当前位置:网站首页>MFC FTP creates multi-level folders and uploads files to the specified directory of FTP
MFC FTP creates multi-level folders and uploads files to the specified directory of FTP
2022-07-27 13:34:00 【sam-zy】
1.FTP Create multi-level folders
//FTP Create multi-level folders
BOOL CFTPDlg::CreateFolderToFtp(CString strFtpPath)
{
try
{
CStringArray Dirs;
ParseCString(strFtpPath, Dirs, '/'); // Character segmentation
CString CurDir =_T("/");
for (int i = 1; i < Dirs.GetCount(); i++)
{
CurDir = CurDir + Dirs[i] + _T("/"); // Create layer by layer
BOOL ret = m_pFtpConnection->CreateDirectory(CurDir);
}
}
catch (CInternetException* pEx)
{
TCHAR szError[100];
if (pEx->GetErrorMessage(szError, 100))
{
AfxMessageBox(szError);
}
pEx->Delete();
m_pFtpConnection = NULL;
if (m_pInetSession)
{
m_pInetSession->Close();
m_pInetSession = NULL;
}
return FALSE;
}
return TRUE;
}
// Test button -1
void CFTPDlg::OnBnClickedDownload2()
{
CreateFolderToFtp(TEXT("/ Folder 1/ Folder 2/ Folder 3")); // Create folder
}

2. Upload files
// To upload pictures
void CFTPDlg::UpFileImage(CString ImagePath, CString ImageName)
{
try
{
Printf1* Atf_Printf1 = (Printf1*)GetParent();
CString strMsg;
CStringArray Dirs;
ParseCString(ImagePath, Dirs, ':'); // Character segmentation ( Get the path after the drive letter )
CreateFolderToFtp(Dirs[1]); //FTP Create directory
if (m_pFtpConnection->PutFile(ImagePath + ImageName, Dirs[1] +ImageName))// To upload pictures
{
strMsg.Format(_T(" Upload the picture successfully strRemoteFile:%s\r\n"), Dirs[1] + ImageName);
Atf_Printf1->Printf1ByValue(strMsg);
DeleteFile(ImagePath + ImageName);// Delete pictures
strMsg.Format(_T(" Delete picture succeeded strLocalFile:%s\r\n"), ImagePath + ImageName);
Atf_Printf1->Printf1ByValue(strMsg);
}
else
{
strMsg.Format(_T(" Failed to upload file , Please check your FTP Whether the server is correct \r\n"));
}
}
catch ()
{
}
}
Execution results :
Upload the picture successfully strRemoteFile:/Image/Ori/2022-07-26/12/YT5636713886474.jpg
Delete picture succeeded strLocalFile:D:/Image/Ori/2022-07-26/12/YT5636713886474.jpg
边栏推荐
- 四大线程池简析
- 电气成套企业如何借助ERP系统,做好成本利润管理?
- Perfect guide | how to use ODBC for agent free Oracle database monitoring?
- 52:第五章:开发admin管理服务:5:开发【分页查询admin账号列表,接口】;(Swagger的@ApiParam(),对方法参数进行注释;PageHelper分页插件;拦截器拦截检查登录状态)
- @Simple understanding and use of conditionalonproperty
- Training in the second week of summer vacation on July 24, 2022
- 51:第五章:开发admin管理服务:4:开发【新增admin账号,接口】;(只开发了【用户名+密码的,方式】;【@T…】注解控制事务;设置cookie时,是否需要使用URLEncoder去编码;)
- 初探基于OSG+OCC的CAD之任意多个子模型进行netgen以及gmsh网格划分
- Can I only use tidb binlog tool to synchronize tidb to MySQL in real time?
- 从tidb实时同步到mysql 只能用 tidb binlog 工具吗?
猜你喜欢

电气成套企业如何借助ERP系统,做好成本利润管理?

How to pass parameters in JNI program

Common types of electric slip rings

Evconnlistener of libevent_ new_ bind

双料第一!

Can you tell me the difference between lateinit and lazy in kotlin?

力扣 1480. 一维数组的动态和 383. 赎金信412. Fizz Buzz
![52: Chapter 5: developing admin management services: 5: developing [paging query admin account list, interface]; (swagger's @apiparam(), annotate the method parameters; PageHelper paging plug-in; Inte](/img/08/1cc315d568673a3892c20bc1254d38.png)
52: Chapter 5: developing admin management services: 5: developing [paging query admin account list, interface]; (swagger's @apiparam(), annotate the method parameters; PageHelper paging plug-in; Inte

马斯克被曝绿了谷歌创始人:导致挚友二婚破裂,曾下跪求原谅

Application of responsibility chain model in transfer accurate valuation
随机推荐
能说一说 Kotlin 中 lateinit 和 lazy 的区别吗?
Rotation chart
Dichotomy queries values in an array
[expression calculation] double stack: general solution of expression calculation problem
[node+ts] build node+typescript project
Interview site: three kinds of questions
Interface testing practical tutorial 01: interface testing environment construction
52:第五章:开发admin管理服务:5:开发【分页查询admin账号列表,接口】;(Swagger的@ApiParam(),对方法参数进行注释;PageHelper分页插件;拦截器拦截检查登录状态)
Will saffron become a safe and effective natural therapy for patients with arthritis?
写出一个程序,接受一个有字母和数字以及空格组成的字符串,和一个字符,然后输出输入字符串中含有该字符的个数。不区分大小写。
Training in the second week of summer vacation on July 24, 2022
How about the strength of database HTAP
libevent 之 evconnlistener_new_bind
Li Kou 1480. Dynamic sum of one-dimensional array 383. Ransom letter 412. Fizz buzz
Application of responsibility chain model in transfer accurate valuation
Height collapse and BFC
初学者入门:使用WordPress搭建一个专属自己的博客
【C语言入门】ZZULIOJ 1021-1025
Redis总结:缓存雪崩、缓存击穿、缓存穿透与缓存预热、缓存降级
Feign's dynamic proxy