當前位置:首頁 » 文件管理 » asp復制文件夾

asp復制文件夾

發布時間: 2022-08-15 04:41:40

① 使用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的簡單升級,而是微軟公司推出的新一代腳本語言。

熱點內容
c語言fread返回值 發布:2025-07-12 16:57:32 瀏覽:678
王者榮耀在哪裡顯示賬號密碼 發布:2025-07-12 16:36:42 瀏覽:898
打包sql資料庫 發布:2025-07-12 16:19:27 瀏覽:797
php日誌查看 發布:2025-07-12 16:12:10 瀏覽:214
ftp目錄映射為本地盤符 發布:2025-07-12 16:06:59 瀏覽:645
nas存儲百科 發布:2025-07-12 16:03:17 瀏覽:126
python的sort函數 發布:2025-07-12 15:53:21 瀏覽:50
ensp伺服器怎麼設置web根目錄 發布:2025-07-12 15:47:56 瀏覽:286
安卓怎麼設置二卡發信息 發布:2025-07-12 15:43:50 瀏覽:743
如何看到無線密碼 發布:2025-07-12 15:43:13 瀏覽:677