asp复制文件夹
① 使用asp.net如果进行文件的复制
给你写一个方法吧
public void CopyFile(string SourceFile, string ObjectFile)
{
string sourceFile = Server.MapPath(SourceFile);
string objectFile = Server.MapPath(ObjectFile);
if (System.IO.File.Exists(sourceFile))
{
System.IO.File.Copy(sourceFile, objectFile, true);
}
}
你可以到处引用这个就行了
② asp中fso复制文件夹
使用fso.CopyFolder.如果你的page在fullpath下,根据用户名来创建的文件夹也在fullpath下,那么假设新建的文件夹名称为UserFolder,那么:
fso.CoypFolder(fullpath&"page",fullpath&"\"&UserFolder&"\")
细节方面自己测试一下,如果你的fullpath本身已经包含"\",取消上面的斜杠就可以了.如果直接在ASP代码里写(不是脚本),需要把参数两边的括号去掉.
③ ASP复制文件夹代码
<%
Function CopyMyFolder(FolderName,FolderPath)
sFolder=server.mappath(FolderName)
oFolder=server.mappath(FolderPath)
set fso=server.createobject("scripting.filesystemobject")
if fso.folderexists(server.mappath(FolderName)) Then'检查原文件夹是否存在
if fso.folderexists(server.mappath(FolderPath)) Then'检查目标文件夹是否存在
fso.folder sFolder,oFolder
Else '目标文件夹如果不存在就创建
CreateNewFolder = Server.Mappath(FolderPath)
fso.CreateFolder(CreateNewFolder)
fso.folder sFolder,oFolder
End if
CopyMyFolder="复制文件夹["&server.mappath(FolderName)&"]到["&server.mappath(FolderPath)&"]成功!"
Else
CopyMyFolder="错误,原文件夹["&sFolde&"]不存在!"
End If
set fso=nothing
End Function
FolderName="原文件夹"
FolderPath="目标文件夹"
response.write""&CopyMyFolder(FolderName,FolderPath)&""
%>
④ asp.net 如何将一个目录下的所有文件复制到另一个目录里面。
private void CopyFile(string sources, string dest)
{
DirectoryInfo dinfo=new DirectoryInfo(sources);//注,这里面传的是路径,并不是文件,所以不能保含带后缀的文件
foreach(FileSystemInfo f in dinfo.GetFileSystemInfos())
{
//目标路径destName = 目标文件夹路径 + 原文件夹下的子文件(或文件夹)名字
//Path.Combine(string a ,string b) 为合并两个字符串
String destName = Path.Combine(dest, fsi.Name);
if (f is FileInfo)//如果是文件就复制
{
File.Copy(f.FullName, destName, true);//true代表可以覆盖同名文件
}
else//如果是文件夹就创建文件夹然后复制然后递归复制
{
Directory.CreateDirectory(destName);
CopyFile(f.FullName, destName);
}
}
}
⑤ 如何通过asp来实现复制文件夹功能
以下是代码:<% sFolder=server.mappath(FolderName) oFolder=server.mappath(FolderPath) set fso=server.createobject("scripting.filesystemobject") if fso.folderexists(server.mappath(FolderName)) Then'检查原文件夹是否存在 if fso.folderexists(server.mappath(FolderPath)) Then'检查目标文件夹是否存在 fso.folder sFolder,oFolder Else '目标文件夹如果不存在就创建 CreateNewFolder = Server.Mappath(FolderPath) fso.CreateFolder(CreateNewFolder) fso.folder sFolder,oFolderEnd ifCopyMyFolder="复制文件夹["&server.mappath(FolderName)&"]到["&server.mappath(FolderPath)&"]成功!"ElseCopyMyFolder="错误,原文件夹["&sFolde&"]不存在!"End Ifset fso=nothing End Function FolderName="2006" '原文件夹 FolderPath="2008" '目标文件夹
⑥ asp 如何 批量的复制指定目录下的文件夹 到指定的目录
思路:
1.用 System.IO.Directory.GetFiles() 方法获得所有文件
2.生成一个泛型列表 List<System.IO.FileInfo> ,然后遍历上面找到的文件并生成 System.IO.FileInfo 对象加入上面的列表。
3.完成
上面的泛型列表可以在最终的Web作为数据绑定用。
⑦ ASP.NET中怎么把一个文件夹内的一个文件复制传到另外一个文件夹内(原文件还在)
//新目录
string newPath ="c:\\";
FileInfo fi = new FileInfo("F:\\xx.js");
//判断目录是否存在
if(!Directory.Exists(newPath))
{
Directory.CreateDirectory(newPath);
}
//复制文件
fi.CopyTo(newPath + fi.Name);
⑧ asp.ASP.NET 怎么把外部图片复制粘贴到项目文件
stringname=FileUpload1。PostedFile。FileName;//客户端文件路径FileInfofile=newFileInfo(name);。
项目之间不可以直接复制图片和源文件的。
ASP。NET又称为ASP+,不仅仅是ASP的简单升级,而是微软公司推出的新一代脚本语言。