导航:首页 > 文件教程 > asp复制文件到文件夹

asp复制文件到文件夹

发布时间:2023-02-11 15:21:55

A. ASP 中,如何用代码将一目录下的文件,转移到另一目录下!要:详细代码,谢谢!! 在ASP网站中!!

<%
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
file1 = server.MapPath("zip") '和当前的asp文件同级
file2 = server.MapPath("files\")
response.Write(file1 & "<br />")
response.Write(file2 & "<hr />")
fso.MoveFolder file1,file2&"\" '注释:把zip文件夹复制到files
response.Write("移动成功")

set fso = nothing
%>
以下是解释-------------------------------------------------
将一个或多个文件夹从某位置移动到另一位置。
object.MoveFolder source, destination
参数
object
必选项。应为 FileSystemObject 的名称。
source
必选项。要移动的文件夹的路径。source 参数字符串仅可在路径的最后一个组成部分中包含通配符。
destination
必选项。指定路径,表示要将文件夹移动到该目标位置。destination 参数不能包含通配符。

B. 批量新建文件夹,并将muban.asp文件复制到每个文件夹下

不清楚你的实际文件/情况,仅以问题中的样例说明及猜测为据;以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI,跟要处理的文件放一起双击运行

@echooff&cd/d"%~dp0"
rem根据一个txt文本文件里的内容创建多个文件夹,并在每个文件夹里生成一个asp文件
set#=Anyquestions&set_=WX&set$=Q&set/az=0x53b7e0b4
title%#%+%$%%$%/%_%%z%
for/f"delims="%%iin('type"nameList.txt"')do(
ifnotexist"%%~i"md"%%~i"
>"%%~imuban.asp"echo;^<scriptlanguage="javascript"type="text/javascript"^>
>>"%%~imuban.asp"echo;window.location="../index.asp?id=%%~i"
>>"%%~imuban.asp"echo;^</script^>
)
echo;%#%+%$%%$%/%_%%z%
pause
exit

C. 关于asp+fso创建文件夹,复制文件的问题

你提供的代码好复杂,所以没有细看,大概是因为路径的关系而出错。以下这个测试无误,需要注意要创建的文件夹及moban文件夹在当前文件的上一目录!
<%
userdir=username
dir=server.MapPath("../"&userdir) '根据你后面的文件地址,确定应该是上一级
set fso = server.CreateObject("Scripting.FileSystemObject")
if not fso.FolderExists(dir) then '如果文件夹不存在则创建
fso.CreateFolder(dir)
end if

file1=server.MapPath("../moban/index.asp")&","&server.MapPath("../moban/list.asp")&","&server.MapPath("../moban/conn.asp")
tofile1=server.MapPath("../"&userdir&"/index.asp")&","&server.MapPath("../"&userdir&"/list.asp")&","&server.MapPath("../"&userdir&"/conn.asp")
'少写点代码 所以放到数组中
filex=split(file1,",")
filey=split(tofile1,",")
for i=0 to ubound(filex) '循环复制文件
call fso.file(filex(i),filey(i))
next
set fso = nothing
%>

D. asp.net如何将一个文件里指定文件命的文件复制到另一个文件夹里

string OrginFile,NewFile;
OrginFile=Server.MapPath(".")+"\\myText.txt"; //文件原始路径
NewFile=Server.MapPath(".")+"\\myTextCoyp.txt";//要放的路径
File.Move(OrginFile,NewFile);

PS:别忘了引入专命名属空间

E. ASP.NET如何将文件由一个文件夹转移到另一个文件夹

给你个例子,代码比较乱,凑合看看吧
string path = @"c:\temp\MyTest.txt";
string path2 = @"c:\temp2\MyTest.txt";
try
{
if (!File.Exists(path))
{
throw new Exception("file not exist");
}

// Ensure that the target does not exist.
if (File.Exists(path2))
File.Delete(path2);

// Move the file.
File.Move(path, path2);
Console.WriteLine("{0} was moved to {1}.", path, path2);

// See if the original exists now.
if (File.Exists(path))
{
Console.WriteLine("The original file still exists, which is unexpected.");
}
else
{
Console.WriteLine("The original file no longer exists, which is expected.");
}

}
catch (Exception e)
{
Console.WriteLine("The process failed: {0}", e.ToString());
}

F. asp.net中如何将图片复制到指定文件夹

if (FileUpload1.FileName.Length != 0)
{
string name = FileUpload1.PostedFile.FileName; // 客户端文件路径回
FileInfo file = new FileInfo(name);
string fileName = file.Name;
string webFilePath = Server.MapPath("~答/Images/Travel" + fileName);
if (File.Exists(webFilePath))
{
FileUpload1.SaveAs(webFilePath);
}
userModel.User_Picture = name;
}

G. 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);
}
}
}

H. asp.net中怎样复制文件

1)引用命名空间
using System.IO;

2)复制文件
File.Copy(Server.MapPath("被复制的文件相对路径"), Server.MapPath("目的位置相对路径"), false);

注意:第三个参数若专为true,那么目标位置存属在同名文件将被覆盖.

不知道对不对,呵呵

阅读全文

与asp复制文件到文件夹相关的资料

热点内容
微信公众号创建好文件怎么发送 浏览:858
xlrd如何将数据写入excel中 浏览:200
微信号货源宣传图 浏览:562
recyclerview版本支持 浏览:98
传输文件出错然后u盘读取不了 浏览:641
编程里面的英文去哪里学方便 浏览:668
90版本天帝tp加点 浏览:117
vivox6和苹果6 浏览:611
编程苦恼怎么办 浏览:140
vuejsref动态改变 浏览:171
哪些软件可用于文件解压 浏览:701
农行u盾原始密码 浏览:371
xp如何弄出一个无线网络连接 浏览:569
word插入pdf只显示文件名称和图标 浏览:150
我想编程一个小软件怎么弄 浏览:168
如何优化文件读取数据java 浏览:262
java敏捷式开发 浏览:800
网页对齐代码快捷键是什么 浏览:304
tomcatlinux文件目录 浏览:520
三星手机能升级系统吗 浏览:683

友情链接