1.java renameTo()
2.VB中删除文件夹
java renameTo()
å¯ä»¥çåï¼ï¼ï¼ï¼
è¦ä¸ä½ ææºç åæ¥ççï¼ï¼ï¼
è¿ä¸ªæ¹æ³æ¯éå½åæ件ãä¸æ¯ç§»å¨æ件ã
ä½ å°åºä»ä¹ææï¼ï¼ï¼ï¼
/*
renameTo
public boolean renameTo(File dest)éæ°å½åæ¤æ½è±¡è·¯å¾å表示çæ件ã
æ¤æ¹æ³è¡ä¸ºç许å¤æ¹é¢é½æ¯ä¸å¹³å°æå ³çï¼éå½åæä½æ æ³å°ä¸ä¸ªæ件ä»ä¸ä¸ªæ件系ç»ç§»å¨å°å¦ä¸ä¸ªæ件系ç»ï¼
该æä½å¯è½ä¸æ¯ååçï¼å¦æå·²ç»åå¨å ·æç®æ æ½è±¡è·¯å¾åçæ件ï¼å该æä½å¯è½æ æ³è·å¾æåã
åºè¯¥å§ç»æ£æ¥è¿åå¼ï¼ç¡®ä¿éå½åæä½æåã
åæ°ï¼
dest - æå®æ件çæ°æ½è±¡è·¯å¾å
è¿åï¼
å½ä¸ä» å½éå½åæåæ¶ï¼è¿å trueï¼å¦åè¿å false
æåºï¼
SecurityException - å¦æåå¨å®å ¨ç®¡çå¨ï¼
ä¸å ¶ SecurityManager.checkWrite(java.lang.String) æ¹æ³æç»å¯¹åæ¥çåæ°çè·¯å¾åè¿è¡åå ¥è®¿é®
NullPointerException - å¦æåæ° dest 为 null
*/
import java.io.*;
public class TestRenameTo {
public static void main(String[] args) throws Exception {
File f = new File("she-äºæ天.mp3");
File test = new File("äºæ天.mp3");
f.renameTo(test);
}
}
VB中删除文件夹
兄台.你复制下面的源码宝塔上面怎么上传源码代码,试试
如果成功的话.能否给个5 分 分给我,呵呵 开玩笑啦
'VB强行删除目录或(VB强行删除文件)模块源码
'需要控件:command1
Public Enum FO_Operation
FO_MOVE = 1
FO_COPY = 2
FO_DELETE = 3
FO_RENAME = 4
End Enum
Public Enum FOFlags
FOF_MULTIDESTFILES = &H1 'Destination specifies multiple files
FOF_SILENT = &H4 'Don't display progress dialog
FOF_RENAMEONCOLLISION = &H8 'Rename if destination already exists
FOF_NOCONFIRMATION = &H 'Don't prompt user
FOF_WANTMAPPINGHANDLE = &H 'Fill in hNameMappings member
FOF_ALLOWUNDO = &H 'Store undo information if possible
FOF_FILESONLY = &H 'On *.*, don't copy directories
FOF_SIMPLEPROGRESS = &H 'Don't show name of each file
FOF_NOCONFIRMMKDIR = &H 'Don't confirm making any needed dirs
End Enum
Public Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As Long ' only used if FOF_SIMPLEPROGRESS
End Type
Private Declare Function SHFileOperation Lib "shell.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private op As SHFILEOPSTRUCT
Public Sub DeleteFolder(sDeleteFolder As String, Optional Interface As Boolean = False)
SetAttr sDeleteFolder, vbNormal
With op
.wFunc = FO_DELETE
.pFrom = sDeleteFolder
.fFlags = IIf(Interface = False, FOF_NOCONFIRMATION, FOF_NOCONFIRMATION And FOF_SILENT)
End With
SHFileOperation op
End Sub
Private Sub Command1_Click()
Call DeleteFolder("D:\新建文件夹", True)
End Sub