js提取指定网站内容( 2022年04月14日13:29:17示例代码介绍)
优采云 发布时间: 2022-04-14 21:24js提取指定网站内容(
2022年04月14日13:29:17示例代码介绍)
C#获取指定目录下设置的某种格式文件并备份到指定文件夹
更新时间:2022-04-14 13:29:17 作者:Farm Code Lifetime
本篇文章介绍C#获取指定目录下设置的一定格式文件并备份到指定文件夹的方法。文章非常详细地介绍了示例代码。对大家的学习或工作有一定的参考价值。有需要的朋友可以参考以下
1.获取文件路径并移动到文件夹信息
string fileName = "";
string sourceFile = @"F:\Test文件夹\CSV";
string bakFilePath = @"F:\Test文件夹\CSV\bak";
2.获取文件夹下的文件信息,移动到bak操作中。
3.文件移动到 Bak 方法
public static ExecutionResult MoveFileToBak(string sourceFile, string bakFilePath, string bakFileName)
{
ExecutionResult result;
FileInfo tempFileInfo;
FileInfo tempBakFileInfo;
DirectoryInfo tempDirectoryInfo;
result = new ExecutionResult();
tempFileInfo = new FileInfo(sourceFile);
tempDirectoryInfo = new DirectoryInfo(bakFilePath);
tempBakFileInfo = new FileInfo(bakFilePath + "\\" + bakFileName);
try
{
if (!tempDirectoryInfo.Exists)
tempDirectoryInfo.Create();
if (tempBakFileInfo.Exists)
tempBakFileInfo.Delete();
//move file to bak
tempFileInfo.MoveTo(bakFilePath + "\\" + bakFileName);
result.Status = true;
result.Message = "Move File To Bak OK";
result.Anything = "SEND OK";
}
catch (Exception ex)
{
result.Status = false;
result.Anything = "SEND Fail";
result.Message = ex.Message;
}
return result;
}
以上就是本文的全部内容。希望对大家的学习有所帮助,也希望大家多多支持编程学习。