|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
About deleting file on Vista 64bitHello,
The File.Delete(VS2005) function can not delete file on Vista-64bit, why? And, what changes of API between 32-bit and 64-bit? Thank you Hi,
There were a lot of security changes in Vista. Are you sure you have permission to delete the file? http://msdn2.microsoft.com/en-us/library/aa480150.aspx Ken --------------------- Show quoteHide quote "yxq" <ga***@163.net> wrote in message news:u4bZQ5mFHHA.1280@TK2MSFTNGP04.phx.gbl... > Hello, > The File.Delete(VS2005) function can not delete file on Vista-64bit, why? > > And, what changes of API between 32-bit and 64-bit? > > Thank you > > Yes, i have the permission(Right-Click the exe file, choose the Run as
Administrator), even i closed the UAC function. "Ken Tucker [MVP]" <vb***@bellsouth.net> ??????:720EDD22-91E7-4971-889C-451761D4D***@microsoft.com...Show quoteHide quote > Hi, > > There were a lot of security changes in Vista. Are you sure > you have permission to delete the file? > > http://msdn2.microsoft.com/en-us/library/aa480150.aspx > > Ken > --------------------- > "yxq" <ga***@163.net> wrote in message > news:u4bZQ5mFHHA.1280@TK2MSFTNGP04.phx.gbl... >> Hello, >> The File.Delete(VS2005) function can not delete file on Vista-64bit, why? >> >> And, what changes of API between 32-bit and 64-bit? >> >> Thank you >> >> > Sorry, the io.file.delete works well, but the API below for x86 will not
work on x64, how to change the API to x64? ////////////////////////////////////////////////////////////////////////////////////// Public Class FileOperate Private Structure SHFILEOPSTRUCT Dim hWnd As Integer Dim wFunc As Integer Dim pFrom As String Dim pTo As String Dim fFlags As Short Dim fAborted As Boolean Dim hNameMaps As Integer Dim sProgress As String End Structure Private Const FO_DELETE As Short = &H3S Private Const FOF_ALLOWUNDO As Int16 = &H40S Private Const FOF_NOCONFIRMATION As Int16 = &H10S Private Const FO_MOVE As Int16 = &H1S Private Const FO_COPY As Int16 = &H2S Private Const FOF_NOERRORUI As Int16 = &H400S Private Const FOF_SILENT As Int16 = &H4S Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (ByRef lpFileOp As SHFILEOPSTRUCT) As Integer Private Shared SHFileOp As SHFILEOPSTRUCT Public Shared Function ShellDirectDelete(ByRef sFile As String, Optional ByVal ShowProgress As Boolean = True) As Int16 sFile = sFile & Chr(0) With SHFileOp .fAborted = True .wFunc = FO_DELETE .pFrom = sFile If ShowProgress = True Then .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI Else .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI + FOF_SILENT End If End With Return SHFileOperation(SHFileOp) End Function Public Shared Function ShellDelToRecycled(ByRef sFile As String, Optional ByVal ShowProgress As Boolean = True) As Int16 sFile = sFile & Chr(0) With SHFileOp .fAborted = True .wFunc = FO_DELETE .pFrom = sFile If ShowProgress = True Then .fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATION + FOF_NOERRORUI Else .fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATION + FOF_NOERRORUI + FOF_SILENT End If End With Return SHFileOperation(SHFileOp) End Function Public Shared Function ShellMove(ByVal SourcePath As String, ByVal DsintedPath As String, Optional ByVal ShowProgress As Boolean = True, _ Optional ByVal MoveEntireDir As Boolean = True) As Int16 If IO.Directory.Exists(DsintedPath) = False Then IO.Directory.CreateDirectory(DsintedPath) Application.DoEvents() If SourcePath.EndsWith("\") Then SourcePath.Remove(SourcePath.Length - 1, 1) If DsintedPath.EndsWith("\") Then DsintedPath.Remove(DsintedPath.Length - 1, 1) With SHFileOp .fAborted = True .wFunc = FO_MOVE If MoveEntireDir = True Then .pFrom = SourcePath & Chr(0) Else .pFrom = SourcePath & "\*.*" End If .pTo = DsintedPath If ShowProgress = True Then .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI Else .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI + FOF_SILENT End If End With Return SHFileOperation(SHFileOp) End Function Public Shared Function ShellCopy(ByVal SourcePath As String, ByVal DsintedPath As String, Optional ByVal ShowProgress As Boolean = True, _ Optional ByVal CopyEntireDir As Boolean = True) As Int16 If IO.Directory.Exists(DsintedPath) = False Then IO.Directory.CreateDirectory(DsintedPath) Application.DoEvents() If SourcePath.EndsWith("\") Then SourcePath.Remove(SourcePath.Length - 1, 1) If DsintedPath.EndsWith("\") Then DsintedPath.Remove(DsintedPath.Length - 1, 1) With SHFileOp .fAborted = True .wFunc = FO_COPY If CopyEntireDir = True Then .pFrom = SourcePath & Chr(0) Else .pFrom = SourcePath & "\*.*" End If .pTo = DsintedPath If ShowProgress = True Then .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI Else .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI + FOF_SILENT End If End With Return SHFileOperation(SHFileOp) End Function End Class Show quoteHide quote "yxq" <ga***@163.net> дÈëÏûÏ¢ÐÂÎÅ:OhYvJarFHHA.1***@TK2MSFTNGP05.phx.gbl... > Yes, i have the permission(Right-Click the exe file, choose the Run as > Administrator), even i closed the UAC function. > > "Ken Tucker [MVP]" <vb***@bellsouth.net> > ??????:720EDD22-91E7-4971-889C-451761D4D***@microsoft.com... >> Hi, >> >> There were a lot of security changes in Vista. Are you sure >> you have permission to delete the file? >> >> http://msdn2.microsoft.com/en-us/library/aa480150.aspx >> >> Ken >> --------------------- >> "yxq" <ga***@163.net> wrote in message >> news:u4bZQ5mFHHA.1280@TK2MSFTNGP04.phx.gbl... >>> Hello, >>> The File.Delete(VS2005) function can not delete file on Vista-64bit, >>> why? >>> >>> And, what changes of API between 32-bit and 64-bit? >>> >>> Thank you >>> >>> >> > > Hi,
Try using an intptr for the hwnd in the structure. A handle is not the same size in a 64bit os as a 32bit one. Private Structure SHFILEOPSTRUCT Dim hWnd As intptr Ken ------------------------- Show quoteHide quote "yxq" <ga***@163.net> wrote in message news:ulAXl0rFHHA.2464@TK2MSFTNGP06.phx.gbl... > Sorry, the io.file.delete works well, but the API below for x86 will not > work on x64, how to change the API to x64? > > ////////////////////////////////////////////////////////////////////////////////////// > Public Class FileOperate > Private Structure SHFILEOPSTRUCT > Dim hWnd As Integer > Dim wFunc As Integer > Dim pFrom As String > Dim pTo As String > Dim fFlags As Short > Dim fAborted As Boolean > Dim hNameMaps As Integer > Dim sProgress As String > End Structure > Private Const FO_DELETE As Short = &H3S > Private Const FOF_ALLOWUNDO As Int16 = &H40S > Private Const FOF_NOCONFIRMATION As Int16 = &H10S > Private Const FO_MOVE As Int16 = &H1S > Private Const FO_COPY As Int16 = &H2S > Private Const FOF_NOERRORUI As Int16 = &H400S > Private Const FOF_SILENT As Int16 = &H4S > > Private Declare Function SHFileOperation Lib "shell32.dll" Alias > "SHFileOperationA" (ByRef lpFileOp As SHFILEOPSTRUCT) As Integer > Private Shared SHFileOp As SHFILEOPSTRUCT > > > Public Shared Function ShellDirectDelete(ByRef sFile As String, > Optional ByVal ShowProgress As Boolean = True) As Int16 > > sFile = sFile & Chr(0) > > With SHFileOp > .fAborted = True > .wFunc = FO_DELETE > .pFrom = sFile > > If ShowProgress = True Then > .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI > Else > .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI + > FOF_SILENT > End If > > End With > Return SHFileOperation(SHFileOp) > End Function > > > Public Shared Function ShellDelToRecycled(ByRef sFile As String, > Optional ByVal ShowProgress As Boolean = True) As Int16 > > sFile = sFile & Chr(0) > > With SHFileOp > .fAborted = True > .wFunc = FO_DELETE > .pFrom = sFile > > If ShowProgress = True Then > .fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATION + > FOF_NOERRORUI > Else > .fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATION + > FOF_NOERRORUI + FOF_SILENT > End If > > End With > Return SHFileOperation(SHFileOp) > End Function > > Public Shared Function ShellMove(ByVal SourcePath As String, ByVal > DsintedPath As String, Optional ByVal ShowProgress As Boolean = True, _ > Optional ByVal MoveEntireDir As Boolean = True) As Int16 > > If IO.Directory.Exists(DsintedPath) = False Then > IO.Directory.CreateDirectory(DsintedPath) > Application.DoEvents() > > If SourcePath.EndsWith("\") Then > SourcePath.Remove(SourcePath.Length - 1, 1) > If DsintedPath.EndsWith("\") Then > DsintedPath.Remove(DsintedPath.Length - 1, 1) > > With SHFileOp > .fAborted = True > .wFunc = FO_MOVE > > If MoveEntireDir = True Then > .pFrom = SourcePath & Chr(0) > Else > .pFrom = SourcePath & "\*.*" > End If > > .pTo = DsintedPath > > If ShowProgress = True Then > .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI > Else > .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI + > FOF_SILENT > End If > > End With > Return SHFileOperation(SHFileOp) > End Function > > Public Shared Function ShellCopy(ByVal SourcePath As String, ByVal > DsintedPath As String, Optional ByVal ShowProgress As Boolean = True, _ > Optional ByVal CopyEntireDir As Boolean = True) As Int16 > > If IO.Directory.Exists(DsintedPath) = False Then > IO.Directory.CreateDirectory(DsintedPath) > Application.DoEvents() > > If SourcePath.EndsWith("\") Then > SourcePath.Remove(SourcePath.Length - 1, 1) > If DsintedPath.EndsWith("\") Then > DsintedPath.Remove(DsintedPath.Length - 1, 1) > > With SHFileOp > .fAborted = True > .wFunc = FO_COPY > > If CopyEntireDir = True Then > .pFrom = SourcePath & Chr(0) > Else > .pFrom = SourcePath & "\*.*" > End If > > .pTo = DsintedPath > > If ShowProgress = True Then > .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI > Else > .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI + > FOF_SILENT > End If > > End With > Return SHFileOperation(SHFileOp) > End Function > > End Class > > > > > > "yxq" <ga***@163.net> > дÈëÏûÏ¢ÐÂÎÅ:OhYvJarFHHA.1***@TK2MSFTNGP05.phx.gbl... >> Yes, i have the permission(Right-Click the exe file, choose the Run as >> Administrator), even i closed the UAC function. >> >> "Ken Tucker [MVP]" <vb***@bellsouth.net> >> ??????:720EDD22-91E7-4971-889C-451761D4D***@microsoft.com... >>> Hi, >>> >>> There were a lot of security changes in Vista. Are you sure >>> you have permission to delete the file? >>> >>> http://msdn2.microsoft.com/en-us/library/aa480150.aspx >>> >>> Ken >>> --------------------- >>> "yxq" <ga***@163.net> wrote in message >>> news:u4bZQ5mFHHA.1280@TK2MSFTNGP04.phx.gbl... >>>> Hello, >>>> The File.Delete(VS2005) function can not delete file on Vista-64bit, >>>> why? >>>> >>>> And, what changes of API between 32-bit and 64-bit? >>>> >>>> Thank you >>>> >>>> >>> >> >> > > Oh, thank you very very much, it works well.
Best Regards YXQ "Ken Tucker [MVP]" <vb***@bellsouth.net> ??????:5E5EAD89-AB92-4E23-9F41-6B522A96F***@microsoft.com...Show quoteHide quote > Hi, > > Try using an intptr for the hwnd in the structure. A handle is > not the same size in a 64bit os as a 32bit one. > > > Private Structure SHFILEOPSTRUCT > Dim hWnd As intptr > > Ken > ------------------------- > "yxq" <ga***@163.net> wrote in message > news:ulAXl0rFHHA.2464@TK2MSFTNGP06.phx.gbl... >> Sorry, the io.file.delete works well, but the API below for x86 will not >> work on x64, how to change the API to x64? >> >> ////////////////////////////////////////////////////////////////////////////////////// >> Public Class FileOperate >> Private Structure SHFILEOPSTRUCT >> Dim hWnd As Integer >> Dim wFunc As Integer >> Dim pFrom As String >> Dim pTo As String >> Dim fFlags As Short >> Dim fAborted As Boolean >> Dim hNameMaps As Integer >> Dim sProgress As String >> End Structure >> Private Const FO_DELETE As Short = &H3S >> Private Const FOF_ALLOWUNDO As Int16 = &H40S >> Private Const FOF_NOCONFIRMATION As Int16 = &H10S >> Private Const FO_MOVE As Int16 = &H1S >> Private Const FO_COPY As Int16 = &H2S >> Private Const FOF_NOERRORUI As Int16 = &H400S >> Private Const FOF_SILENT As Int16 = &H4S >> >> Private Declare Function SHFileOperation Lib "shell32.dll" Alias >> "SHFileOperationA" (ByRef lpFileOp As SHFILEOPSTRUCT) As Integer >> Private Shared SHFileOp As SHFILEOPSTRUCT >> >> >> Public Shared Function ShellDirectDelete(ByRef sFile As String, >> Optional ByVal ShowProgress As Boolean = True) As Int16 >> >> sFile = sFile & Chr(0) >> >> With SHFileOp >> .fAborted = True >> .wFunc = FO_DELETE >> .pFrom = sFile >> >> If ShowProgress = True Then >> .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI >> Else >> .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI + >> FOF_SILENT >> End If >> >> End With >> Return SHFileOperation(SHFileOp) >> End Function >> >> >> Public Shared Function ShellDelToRecycled(ByRef sFile As String, >> Optional ByVal ShowProgress As Boolean = True) As Int16 >> >> sFile = sFile & Chr(0) >> >> With SHFileOp >> .fAborted = True >> .wFunc = FO_DELETE >> .pFrom = sFile >> >> If ShowProgress = True Then >> .fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATION + >> FOF_NOERRORUI >> Else >> .fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATION + >> FOF_NOERRORUI + FOF_SILENT >> End If >> >> End With >> Return SHFileOperation(SHFileOp) >> End Function >> >> Public Shared Function ShellMove(ByVal SourcePath As String, ByVal >> DsintedPath As String, Optional ByVal ShowProgress As Boolean = True, _ >> Optional ByVal MoveEntireDir As Boolean = True) As Int16 >> >> If IO.Directory.Exists(DsintedPath) = False Then >> IO.Directory.CreateDirectory(DsintedPath) >> Application.DoEvents() >> >> If SourcePath.EndsWith("\") Then >> SourcePath.Remove(SourcePath.Length - 1, 1) >> If DsintedPath.EndsWith("\") Then >> DsintedPath.Remove(DsintedPath.Length - 1, 1) >> >> With SHFileOp >> .fAborted = True >> .wFunc = FO_MOVE >> >> If MoveEntireDir = True Then >> .pFrom = SourcePath & Chr(0) >> Else >> .pFrom = SourcePath & "\*.*" >> End If >> >> .pTo = DsintedPath >> >> If ShowProgress = True Then >> .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI >> Else >> .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI + >> FOF_SILENT >> End If >> >> End With >> Return SHFileOperation(SHFileOp) >> End Function >> >> Public Shared Function ShellCopy(ByVal SourcePath As String, ByVal >> DsintedPath As String, Optional ByVal ShowProgress As Boolean = True, _ >> Optional ByVal CopyEntireDir As Boolean = True) As Int16 >> >> If IO.Directory.Exists(DsintedPath) = False Then >> IO.Directory.CreateDirectory(DsintedPath) >> Application.DoEvents() >> >> If SourcePath.EndsWith("\") Then >> SourcePath.Remove(SourcePath.Length - 1, 1) >> If DsintedPath.EndsWith("\") Then >> DsintedPath.Remove(DsintedPath.Length - 1, 1) >> >> With SHFileOp >> .fAborted = True >> .wFunc = FO_COPY >> >> If CopyEntireDir = True Then >> .pFrom = SourcePath & Chr(0) >> Else >> .pFrom = SourcePath & "\*.*" >> End If >> >> .pTo = DsintedPath >> >> If ShowProgress = True Then >> .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI >> Else >> .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI + >> FOF_SILENT >> End If >> >> End With >> Return SHFileOperation(SHFileOp) >> End Function >> >> End Class >> >> >> >> >> >> "yxq" <ga***@163.net> >> дÈëÏûÏ¢ÐÂÎÅ:OhYvJarFHHA.1***@TK2MSFTNGP05.phx.gbl... >>> Yes, i have the permission(Right-Click the exe file, choose the Run as >>> Administrator), even i closed the UAC function. >>> >>> "Ken Tucker [MVP]" <vb***@bellsouth.net> >>> ??????:720EDD22-91E7-4971-889C-451761D4D***@microsoft.com... >>>> Hi, >>>> >>>> There were a lot of security changes in Vista. Are you sure >>>> you have permission to delete the file? >>>> >>>> http://msdn2.microsoft.com/en-us/library/aa480150.aspx >>>> >>>> Ken >>>> --------------------- >>>> "yxq" <ga***@163.net> wrote in message >>>> news:u4bZQ5mFHHA.1280@TK2MSFTNGP04.phx.gbl... >>>>> Hello, >>>>> The File.Delete(VS2005) function can not delete file on Vista-64bit, >>>>> why? >>>>> >>>>> And, what changes of API between 32-bit and 64-bit? >>>>> >>>>> Thank you >>>>> >>>>> >>>> >>> >>> >> >> > Could you please view the API below, them will not work on 64bit.
I have change the Dim hwnd As Integer to Dim hwnd As Intptr, but it will not work yet. Thank you ///////////////////////////////////////////////////////////////// Private Declare Function ShellExecuteEx Lib "shell32.dll" (ByRef lpExecInfo As SHELLEXECUTEINFO) As Integer Private Const SW_NORMAL As Integer = 1 Private Const SW_SHOW As Integer = 5 Private Const SEE_MASK_NOCLOSEPROCESS As Integer = &H40S Private Structure SHELLEXECUTEINFO Dim cbSize As Integer Dim fMask As Integer Dim hwnd As Integer Dim lpVerb As String Dim lpFile As String Dim lpParameters As String Dim lpDirectory As String Dim nShow As Integer Dim hInstApp As Integer ' fields Dim lpIDList As Integer Dim lpClass As String Dim hkeyClass As Integer Dim dwHotKey As Integer Dim hIcon As Integer Dim hProcess As Integer End Structure Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer Show quoteHide quote "yxq" <ga***@163.net> дÈëÏûÏ¢ÐÂÎÅ:%23s4B$s5FHHA.1***@TK2MSFTNGP03.phx.gbl... > Oh, thank you very very much, it works well. > > Best Regards > YXQ > > "Ken Tucker [MVP]" <vb***@bellsouth.net> > ??????:5E5EAD89-AB92-4E23-9F41-6B522A96F***@microsoft.com... >> Hi, >> >> Try using an intptr for the hwnd in the structure. A handle >> is not the same size in a 64bit os as a 32bit one. >> >> >> Private Structure SHFILEOPSTRUCT >> Dim hWnd As intptr >> >> Ken >> ------------------------- >> "yxq" <ga***@163.net> wrote in message >> news:ulAXl0rFHHA.2464@TK2MSFTNGP06.phx.gbl... >>> Sorry, the io.file.delete works well, but the API below for x86 will not >>> work on x64, how to change the API to x64? >>> >>> ////////////////////////////////////////////////////////////////////////////////////// >>> Public Class FileOperate >>> Private Structure SHFILEOPSTRUCT >>> Dim hWnd As Integer >>> Dim wFunc As Integer >>> Dim pFrom As String >>> Dim pTo As String >>> Dim fFlags As Short >>> Dim fAborted As Boolean >>> Dim hNameMaps As Integer >>> Dim sProgress As String >>> End Structure >>> Private Const FO_DELETE As Short = &H3S >>> Private Const FOF_ALLOWUNDO As Int16 = &H40S >>> Private Const FOF_NOCONFIRMATION As Int16 = &H10S >>> Private Const FO_MOVE As Int16 = &H1S >>> Private Const FO_COPY As Int16 = &H2S >>> Private Const FOF_NOERRORUI As Int16 = &H400S >>> Private Const FOF_SILENT As Int16 = &H4S >>> >>> Private Declare Function SHFileOperation Lib "shell32.dll" Alias >>> "SHFileOperationA" (ByRef lpFileOp As SHFILEOPSTRUCT) As Integer >>> Private Shared SHFileOp As SHFILEOPSTRUCT >>> >>> >>> Public Shared Function ShellDirectDelete(ByRef sFile As String, >>> Optional ByVal ShowProgress As Boolean = True) As Int16 >>> >>> sFile = sFile & Chr(0) >>> >>> With SHFileOp >>> .fAborted = True >>> .wFunc = FO_DELETE >>> .pFrom = sFile >>> >>> If ShowProgress = True Then >>> .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI >>> Else >>> .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI + >>> FOF_SILENT >>> End If >>> >>> End With >>> Return SHFileOperation(SHFileOp) >>> End Function >>> >>> >>> Public Shared Function ShellDelToRecycled(ByRef sFile As String, >>> Optional ByVal ShowProgress As Boolean = True) As Int16 >>> >>> sFile = sFile & Chr(0) >>> >>> With SHFileOp >>> .fAborted = True >>> .wFunc = FO_DELETE >>> .pFrom = sFile >>> >>> If ShowProgress = True Then >>> .fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATION + >>> FOF_NOERRORUI >>> Else >>> .fFlags = FOF_ALLOWUNDO + FOF_NOCONFIRMATION + >>> FOF_NOERRORUI + FOF_SILENT >>> End If >>> >>> End With >>> Return SHFileOperation(SHFileOp) >>> End Function >>> >>> Public Shared Function ShellMove(ByVal SourcePath As String, ByVal >>> DsintedPath As String, Optional ByVal ShowProgress As Boolean = True, _ >>> Optional ByVal MoveEntireDir As Boolean = True) As Int16 >>> >>> If IO.Directory.Exists(DsintedPath) = False Then >>> IO.Directory.CreateDirectory(DsintedPath) >>> Application.DoEvents() >>> >>> If SourcePath.EndsWith("\") Then >>> SourcePath.Remove(SourcePath.Length - 1, 1) >>> If DsintedPath.EndsWith("\") Then >>> DsintedPath.Remove(DsintedPath.Length - 1, 1) >>> >>> With SHFileOp >>> .fAborted = True >>> .wFunc = FO_MOVE >>> >>> If MoveEntireDir = True Then >>> .pFrom = SourcePath & Chr(0) >>> Else >>> .pFrom = SourcePath & "\*.*" >>> End If >>> >>> .pTo = DsintedPath >>> >>> If ShowProgress = True Then >>> .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI >>> Else >>> .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI + >>> FOF_SILENT >>> End If >>> >>> End With >>> Return SHFileOperation(SHFileOp) >>> End Function >>> >>> Public Shared Function ShellCopy(ByVal SourcePath As String, ByVal >>> DsintedPath As String, Optional ByVal ShowProgress As Boolean = True, _ >>> Optional ByVal CopyEntireDir As Boolean = True) As Int16 >>> >>> If IO.Directory.Exists(DsintedPath) = False Then >>> IO.Directory.CreateDirectory(DsintedPath) >>> Application.DoEvents() >>> >>> If SourcePath.EndsWith("\") Then >>> SourcePath.Remove(SourcePath.Length - 1, 1) >>> If DsintedPath.EndsWith("\") Then >>> DsintedPath.Remove(DsintedPath.Length - 1, 1) >>> >>> With SHFileOp >>> .fAborted = True >>> .wFunc = FO_COPY >>> >>> If CopyEntireDir = True Then >>> .pFrom = SourcePath & Chr(0) >>> Else >>> .pFrom = SourcePath & "\*.*" >>> End If >>> >>> .pTo = DsintedPath >>> >>> If ShowProgress = True Then >>> .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI >>> Else >>> .fFlags = 0 + FOF_NOCONFIRMATION + FOF_NOERRORUI + >>> FOF_SILENT >>> End If >>> >>> End With >>> Return SHFileOperation(SHFileOp) >>> End Function >>> >>> End Class >>> >>> >>> >>> >>> >>> "yxq" <ga***@163.net> дÈëÏûÏ¢ÐÂÎÅ:OhYvJarFHHA.1***@TK2MSFTNGP05.phx.gbl... >>>> Yes, i have the permission(Right-Click the exe file, choose the Run as >>>> Administrator), even i closed the UAC function. >>>> >>>> "Ken Tucker [MVP]" <vb***@bellsouth.net> >>>> ??????:720EDD22-91E7-4971-889C-451761D4D***@microsoft.com... >>>>> Hi, >>>>> >>>>> There were a lot of security changes in Vista. Are you >>>>> sure you have permission to delete the file? >>>>> >>>>> http://msdn2.microsoft.com/en-us/library/aa480150.aspx >>>>> >>>>> Ken >>>>> --------------------- >>>>> "yxq" <ga***@163.net> wrote in message >>>>> news:u4bZQ5mFHHA.1280@TK2MSFTNGP04.phx.gbl... >>>>>> Hello, >>>>>> The File.Delete(VS2005) function can not delete file on Vista-64bit, >>>>>> why? >>>>>> >>>>>> And, what changes of API between 32-bit and 64-bit? >>>>>> >>>>>> Thank you >>>>>> >>>>>> >>>>> >>>> >>>> >>> >>> >> > > >
enter key press
best way to learn Windows Forms Database Connection Designer Variables Newbie: error trying to save directory path to database Working with a database How to set an objects property using Reflection PIAs for Excel 9.0 Make Code Fail Select All CheckBoxes Key Validation How Do I Kill Non-Printable Characters? |
|||||||||||||||||||||||