/**
* 判断文件的目录是否存,不存则创建
*/
public void CheckDirectoryExist(string destFilePath)
{
string fullDir = ParseDirectory(destFilePath);
string[] dirs = fullDir.Split('/');
string curDir = "/";
for (int i = 0; i < dirs.Length; i++)
{
string dir = dirs[i];
//如果是以/开始的路径,第一个为空
if (dir != null && dir.Length > 0)
{
try
{
curDir += dir+"/";
MakeDirectory(curDir);
}
catch (Exception)
{
}
}
}
}
public string ParseDirectory(string destFilePath)
{
return destFilePath.Substring(0, destFilePath.LastIndexOf("/"));
}
FtpWebRequest创建多层目录
最新推荐文章于 2024-01-29 23:00:26 发布